Rob Shearman : oleaut32: Don' t call SafeArrayAllocData in LPSAFEARRAY_UserUnmarshal if we called SafeArrayCreateEx instead of SafeArrayAllocDescriptor .

Alexandre Julliard julliard at winehq.org
Fri Dec 7 11:01:58 CST 2007


Module: wine
Branch: master
Commit: baccba317e4472ae2cbfa2075b15ce9a3af3a5e1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=baccba317e4472ae2cbfa2075b15ce9a3af3a5e1

Author: Rob Shearman <rob at codeweavers.com>
Date:   Fri Dec  7 14:13:57 2007 +0000

oleaut32: Don't call SafeArrayAllocData in LPSAFEARRAY_UserUnmarshal if we called SafeArrayCreateEx instead of SafeArrayAllocDescriptor.

Otherwise, we'll leak memory.

---

 dlls/oleaut32/usrmarshal.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/oleaut32/usrmarshal.c b/dlls/oleaut32/usrmarshal.c
index 3f84fab..49570f4 100644
--- a/dlls/oleaut32/usrmarshal.c
+++ b/dlls/oleaut32/usrmarshal.c
@@ -1048,9 +1048,14 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
     (*ppsa)->cbElements = wiresa->cbElements;
     (*ppsa)->cLocks = LOWORD(wiresa->cLocks);
 
-    hr = SafeArrayAllocData(*ppsa);
-    if (FAILED(hr))
-        RpcRaiseException(hr);
+    /* SafeArrayCreateEx allocates the data for us, but
+     * SafeArrayAllocDescriptor doesn't */
+    if(!vt)
+    {
+        hr = SafeArrayAllocData(*ppsa);
+        if (FAILED(hr))
+            RpcRaiseException(hr);
+    }
 
     if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
         RpcRaiseException(RPC_S_INVALID_BOUND);




More information about the wine-cvs mailing list