[PATCH 2/2] shell32/tests: Check IDispatch for NULL before using its functions

Fabian Maurer dark.shadow4 at web.de
Mon Sep 25 13:34:13 CDT 2017


Fixes Bug 43749

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/shell32/tests/shelldispatch.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index 7b5afa0c94..b31497b557 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -134,13 +134,15 @@ static void test_namespace(void)
     r = IShellDispatch_get_Application(sd, &disp);
     ok(r == S_OK, "Failed to get application pointer, hr %#x.\n", r);
     ok(disp == (IDispatch *)sd, "Unexpected application pointer %p.\n", disp);
-    IDispatch_Release(disp);
+    if(disp)
+        IDispatch_Release(disp);
 
     disp = NULL;
     r = IShellDispatch_get_Parent(sd, &disp);
     ok(r == S_OK, "Failed to get Shell object parent, hr %#x.\n", r);
     ok(disp == (IDispatch *)sd, "Unexpected parent pointer %p.\n", disp);
-    IDispatch_Release(disp);
+    if(disp)
+        IDispatch_Release(disp);
 
     VariantInit(&var);
     folder = (void*)0xdeadbeef;
@@ -502,7 +504,8 @@ static void test_items(void)
     r = FolderItem_get_Parent(item, &disp);
     ok(r == S_OK, "Failed to get parent pointer, hr %#x.\n", r);
     ok(disp == (IDispatch *)folder, "Unexpected parent pointer %p.\n", disp);
-    IDispatch_Release(disp);
+    if(disp)
+        IDispatch_Release(disp);
 
     if (item) FolderItem_Release(item);
     VariantClear(&var);
@@ -1036,6 +1039,10 @@ todo_wine {
         ok(disp == NULL, "got %p\n", disp);
         ok(ret == 0, "got %d\n", ret);
     }
+    else if (disp == NULL) {
+        ok(FALSE, "disp is NULL\n");
+        skip("disp is NULL\n");
+    }
     else {
         static const IID *browser_riids[] = {
             &IID_IWebBrowser2,
@@ -1055,7 +1062,6 @@ todo_wine {
         IShellView *sv;
         IUnknown *unk;
 
-        ok(disp != NULL, "got %p\n", disp);
         ok(ret != HandleToUlong(hwnd), "got %d\n", ret);
 
         /* IDispatch-related tests */
-- 
2.14.1




More information about the wine-patches mailing list