Vincent Povirk : ole32: Fix a memory leak in StorageBaseImpl_CopyTo.

Alexandre Julliard julliard at winehq.org
Mon Dec 14 09:51:16 CST 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sun Dec 13 18:16:56 2009 -0600

ole32: Fix a memory leak in StorageBaseImpl_CopyTo.

Spotted by valgrind.

---

 dlls/ole32/storage32.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 479c2a5..00ffe89 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -1656,12 +1656,12 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
     }
 
     if ( skip )
-      continue;
+      goto cleanup;
 
     if (curElement.type == STGTY_STORAGE)
     {
       if(skip_storage)
-        continue;
+        goto cleanup;
 
       /*
        * open child source storage
@@ -1671,7 +1671,7 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
 				 NULL, 0, &pstgChild );
 
       if (hr != S_OK)
-        break;
+        goto cleanup;
 
       /*
        * Check if destination storage is not a child of the source
@@ -1679,9 +1679,8 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
        */
       if (pstgChild == pstgDest)
       {
-	IEnumSTATSTG_Release(elements);
-
-	return STG_E_ACCESSDENIED;
+        hr = STG_E_ACCESSDENIED;
+        goto cleanup;
       }
 
       /*
@@ -1702,7 +1701,7 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
       }
 
       if (hr != S_OK)
-        break;
+        goto cleanup;
 
 
       /*
@@ -1717,7 +1716,7 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
     else if (curElement.type == STGTY_STREAM)
     {
       if(skip_stream)
-        continue;
+        goto cleanup;
 
       /*
        * create a new stream in destination storage. If the stream already
@@ -1728,7 +1727,7 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
                                   0, 0, &pstrTmp );
 
       if (hr != S_OK)
-        break;
+        goto cleanup;
 
       /*
        * open child stream storage
@@ -1738,7 +1737,7 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
 				0, &pstrChild );
 
       if (hr != S_OK)
-        break;
+        goto cleanup;
 
       /*
        * Get the size of the source stream
@@ -1764,6 +1763,8 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
       WARN("unknown element type: %d\n", curElement.type);
     }
 
+cleanup:
+    CoTaskMemFree(curElement.pwcsName);
   } while (hr == S_OK);
 
   /*




More information about the wine-cvs mailing list