Commit 63316d09 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Return DDERR_INVALIDPARAMS for 0 width / height surface creation.

parent f683fe31
......@@ -3069,6 +3069,12 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
desc2.dwHeight = Mode.Height;
}
if (!desc2.dwWidth || !desc2.dwHeight)
{
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
/* Mipmap count fixes */
if(desc2.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
{
......
......@@ -2391,6 +2391,30 @@ static void SizeTest(void)
dsurface = NULL;
}
/* Test 0 height. */
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
desc.dwWidth = 1;
desc.dwHeight = 0;
ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 height surface returned %#x, expected DDERR_INVALIDPARAMS.\n", ret);
if (SUCCEEDED(ret)) IDirectDrawSurface_Release(dsurface);
dsurface = NULL;
/* Test 0 width. */
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
desc.dwWidth = 0;
desc.dwHeight = 1;
ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 width surface returned %#x, expected DDERR_INVALIDPARAMS.\n", ret);
if (SUCCEEDED(ret)) IDirectDrawSurface_Release(dsurface);
dsurface = NULL;
/* Sanity check */
ZeroMemory(&desc, sizeof(desc));
desc.dwSize = sizeof(desc);
......
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