From f717b561aee00363e29bfc5af16c2a7b1b6a6c14 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sun, 13 Dec 2009 18:16:56 -0600 Subject: [PATCH 1/3] 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); /* -- 1.6.3.3