[PATCH v2 1/4] ddraw: Don't write out if a ddraw1 surface of size 0 is requested.

Alex Henrie alexhenrie24 at gmail.com
Wed Jan 25 23:20:38 CST 2017


Fixes https://bugs.winehq.org/show_bug.cgi?id=42159

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/ddraw/ddraw.c        | 3 ---
 dlls/ddraw/tests/ddraw1.c | 8 +++++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index e313a7500e..d22042a9aa 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2975,10 +2975,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
     hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 1);
     wined3d_mutex_unlock();
     if (FAILED(hr))
-    {
-        *surface = NULL;
         return hr;
-    }
 
     *surface = &impl->IDirectDrawSurface_iface;
     impl->ifaceToRelease = NULL;
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index ed4c5ec493..14bc1ecdc4 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -1932,7 +1932,7 @@ static void test_surface_qi(void)
         {&IID_IUnknown,                 &IID_IDirectDrawSurface,        S_OK         },
     };
 
-    IDirectDrawSurface *surface;
+    IDirectDrawSurface *surface = (IDirectDrawSurface *)0xdeadbeef;
     DDSURFACEDESC surface_desc;
     IDirect3DDevice *device;
     IDirectDraw *ddraw;
@@ -1965,6 +1965,12 @@ static void test_surface_qi(void)
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
+
+    hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(surface == (IDirectDrawSurface *)0xdeadbeef || broken(!surface) /* 32-bit on Win8/10 */,
+            "Got unexpected surface %p.\n", surface);
+
     surface_desc.dwWidth = 512;
     surface_desc.dwHeight = 512;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-- 
2.11.0




More information about the wine-patches mailing list