[PATCH] ddraw/tests: Avoid dereferencing a null pointer in case of failure.

Zebediah Figura z.figura12 at gmail.com
Sat Oct 21 17:32:48 CDT 2017


This should fix a persistent crash on one of the XP test machines.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ddraw/tests/ddraw1.c | 3 ++-
 dlls/ddraw/tests/ddraw2.c | 3 ++-
 dlls/ddraw/tests/ddraw4.c | 7 ++++++-
 dlls/ddraw/tests/ddraw7.c | 7 ++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index c052c03..4135814 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -462,7 +462,8 @@ static IDirect3DDevice *create_device(IDirectDraw *ddraw, HWND window, DWORD coo
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Failed to create surface, hr %#x.\n", hr);
+    if (FAILED(hr)) return NULL;
 
     if (coop_level & DDSCL_NORMAL)
     {
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 9d77521..1c7c36f 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -333,7 +333,8 @@ static IDirect3DDevice2 *create_device(IDirectDraw2 *ddraw, HWND window, DWORD c
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Failed to create surface, hr %#x.\n", hr);
+    if (FAILED(hr)) return NULL;
 
     if (coop_level & DDSCL_NORMAL)
     {
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index b401544..77b9d84 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -316,7 +316,12 @@ static IDirect3DDevice3 *create_device(HWND window, DWORD coop_level)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Failed to create surface, hr %#x.\n", hr);
+    if (FAILED(hr))
+    {
+        IDirectDraw4_Release(ddraw4);
+        return NULL;
+    }
 
     if (coop_level & DDSCL_NORMAL)
     {
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 00c7919..7fab179 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -332,7 +332,12 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Failed to create surface, hr %#x.\n", hr);
+    if (FAILED(hr))
+    {
+        IDirectDraw7_Release(ddraw);
+        return NULL;
+    }
 
     if (coop_level & DDSCL_NORMAL)
     {
-- 
2.7.4




More information about the wine-patches mailing list