Commit f6997e8f authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

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

parent d9f2b462
......@@ -2924,14 +2924,22 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 2);
wined3d_mutex_unlock();
if (FAILED(hr))
__TRY
{
*surface = NULL;
return hr;
if (FAILED(hr))
{
*surface = NULL;
break;
}
*surface = &impl->IDirectDrawSurface_iface;
impl->ifaceToRelease = NULL;
}
*surface = &impl->IDirectDrawSurface_iface;
impl->ifaceToRelease = NULL;
__EXCEPT_PAGE_FAULT
{
hr = E_INVALIDARG;
}
__ENDTRY;
return hr;
}
......
......@@ -2119,6 +2119,8 @@ static void test_surface_qi(void)
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 512;
surface_desc.dwHeight = 512;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface **)0xdeadbeef, NULL);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
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