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

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alex Henrie 2017-01-28 15:34:03 -07:00 committed by Alexandre Julliard
parent 37fcb0d630
commit d9f2b4627a
2 changed files with 19 additions and 7 deletions

View File

@ -26,6 +26,8 @@
#include "ddraw_private.h"
#include "wine/exception.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const struct ddraw *exclusive_ddraw;
@ -2974,14 +2976,22 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
DDSD_to_DDSD2(surface_desc, &surface_desc2);
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;
__TRY
{
if (FAILED(hr))
{
*surface = NULL;
break;
}
*surface = &impl->IDirectDrawSurface_iface;
impl->ifaceToRelease = NULL;
}
__EXCEPT_PAGE_FAULT
{
hr = E_INVALIDARG;
}
__ENDTRY;
return hr;
}

View File

@ -1967,6 +1967,8 @@ static void test_surface_qi(void)
surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
surface_desc.dwWidth = 512;
surface_desc.dwHeight = 512;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface **)0xdeadbeef, NULL);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);