Theodore Dubois : shell32/tests: Fix memory leaks.
Alexandre Julliard
julliard at winehq.org
Wed Jun 8 11:07:35 CDT 2016
Module: wine
Branch: master
Commit: 2a7c4ea8753a42155231de9fc3fb3e4d03a4ba2a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2a7c4ea8753a42155231de9fc3fb3e4d03a4ba2a
Author: Theodore Dubois <tblodt at icloud.com>
Date: Sun Jun 5 09:35:39 2016 -0700
shell32/tests: Fix memory leaks.
Signed-off-by: Theodore Dubois <tblodt at icloud.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/tests/assoc.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/tests/assoc.c b/dlls/shell32/tests/assoc.c
index beebbdf..274c0fc 100644
--- a/dlls/shell32/tests/assoc.c
+++ b/dlls/shell32/tests/assoc.c
@@ -104,7 +104,7 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
{
IQueryAssociations *assoc;
HRESULT hr;
- WCHAR *buffer;
+ WCHAR *buffer = NULL;
DWORD len;
hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&assoc);
@@ -115,8 +115,11 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, NULL, &len);
if (expected_string) {
ok_(__FILE__, line)(hr == S_FALSE, "GetString returned 0x%x, expected S_FALSE\n", hr);
- if (hr != S_FALSE)
- return; /* don't try to allocate memory */
+ if (hr != S_FALSE) {
+ /* don't try to allocate memory using unitialized len */
+ IQueryAssociations_Release(assoc);
+ return;
+ }
buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
@@ -128,6 +131,9 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
} else {
ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr);
}
+
+ IQueryAssociations_Release(assoc);
+ HeapFree(GetProcessHeap(), 0, buffer);
}
static void test_IQueryAssociations_GetString(void)
More information about the wine-cvs
mailing list