Theodore Dubois : shell32/tests: Fix out of memory errors and their underlying cause.

Alexandre Julliard julliard at winehq.org
Wed Jun 8 11:07:35 CDT 2016


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

Author: Theodore Dubois <tblodt at icloud.com>
Date:   Sun Jun  5 09:35:38 2016 -0700

shell32/tests: Fix out of memory errors and their underlying cause.

The out of memory errors were happening because getstring_test was using
len unitialized when GetString failed. The underlying cause was that
deleting the keys would fail because RegDeleteKey does not work if the
key has subkeys, and one of the keys has a subkey. The test fails when
the keys are still there. The subkey is now deleted before the key that
contains it.

Signed-off-by: Theodore Dubois <tblodt at icloud.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shell32/tests/assoc.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/dlls/shell32/tests/assoc.c b/dlls/shell32/tests/assoc.c
index 67f7d32..beebbdf 100644
--- a/dlls/shell32/tests/assoc.c
+++ b/dlls/shell32/tests/assoc.c
@@ -113,21 +113,20 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
     ok_(__FILE__, line)(hr == S_OK, "IQueryAssociations::Init failed, 0x%x\n", hr);
 
     hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, NULL, &len);
-    if (hr != S_FALSE) {
-        if (expected_string) {
-            ok_(__FILE__, line)(SUCCEEDED(hr), "GetString returned 0x%x, expected success\n", hr);
-        } else {
-            ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr);
-        }
-    }
+    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 */
 
-    buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
-    ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
-    hr = IQueryAssociations_GetString(assoc, ASSOCF_NONE, str, NULL, buffer, &len);
+        buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
+        hr = IQueryAssociations_GetString(assoc, 0, str, NULL, buffer, &len);
+        ok_(__FILE__, line)(hr == S_OK, "GetString returned 0x%x, expected S_OK\n", hr);
 
-    if (expected_string) {
         ok_(__FILE__, line)(lstrcmpW(buffer, expected_string) == 0, "GetString returned %s, expected %s\n",
                 wine_dbgstr_w(buffer), wine_dbgstr_w(expected_string));
+    } else {
+        ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%x, expected failure\n", hr);
     }
 }
 
@@ -176,8 +175,9 @@ static void test_IQueryAssociations_GetString(void)
     getstring_test(test_progidW, NULL, ASSOCSTR_DEFAULTICON, test_iconW, __LINE__);
     getstring_test(NULL, test_progid_key, ASSOCSTR_DEFAULTICON, test_iconW, __LINE__);
 
-    RegDeleteKeyW(HKEY_CLASSES_ROOT, test_extensionW);
+    RegDeleteKeyW(test_progid_key, DefaultIconW);
     RegDeleteKeyW(HKEY_CLASSES_ROOT, test_progidW);
+    RegDeleteKeyW(HKEY_CLASSES_ROOT, test_extensionW);
 
     hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&assoc);
     ok(hr == S_OK, "failed to create object, 0x%x\n", hr);




More information about the wine-cvs mailing list