Commit 1850ac57 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ddraw: Don't crash if writing out a new ddraw4 surface segfaults.

parent f6997e8f
...@@ -2868,15 +2868,23 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface, ...@@ -2868,15 +2868,23 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 4); hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 4);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (FAILED(hr))
__TRY
{ {
*surface = NULL; if (FAILED(hr))
return hr; {
*surface = NULL;
break;
}
*surface = &impl->IDirectDrawSurface4_iface;
IDirectDraw4_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
} }
__EXCEPT_PAGE_FAULT
*surface = &impl->IDirectDrawSurface4_iface; {
IDirectDraw4_AddRef(iface); hr = E_INVALIDARG;
impl->ifaceToRelease = (IUnknown *)iface; }
__ENDTRY;
return hr; return hr;
} }
......
...@@ -2267,6 +2267,8 @@ static void test_surface_qi(void) ...@@ -2267,6 +2267,8 @@ static void test_surface_qi(void)
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 512; surface_desc.dwWidth = 512;
surface_desc.dwHeight = 512; surface_desc.dwHeight = 512;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface4 **)0xdeadbeef, NULL);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment