d3d8: Clear pBits and Pitch when d3d8_surface_LockRect() fails.

This is a only slightly modified version of a patch by Lasse Rasinen.
This commit is contained in:
Henri Verbeet 2013-11-12 11:00:25 +01:00 committed by Alexandre Julliard
parent f5d807b7d7
commit b83a0b9d3e
2 changed files with 14 additions and 2 deletions

View File

@ -273,8 +273,16 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect, flags);
wined3d_mutex_unlock();
locked_rect->Pitch = map_desc.row_pitch;
locked_rect->pBits = map_desc.data;
if (SUCCEEDED(hr))
{
locked_rect->Pitch = map_desc.row_pitch;
locked_rect->pBits = map_desc.data;
}
else
{
locked_rect->Pitch = 0;
locked_rect->pBits = NULL;
}
return hr;
}

View File

@ -4039,8 +4039,12 @@ static void test_lockrect_invalid(void)
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, NULL, 0);
ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#x.\n", hr);
locked_rect.pBits = (void *)0xdeadbeef;
locked_rect.Pitch = 1;
hr = IDirect3DSurface8_LockRect(surface, &locked_rect, NULL, 0);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
ok(!locked_rect.pBits, "Got unexpected pBits %p.\n", locked_rect.pBits);
ok(!locked_rect.Pitch, "Got unexpected Pitch %u.\n", locked_rect.Pitch);
hr = IDirect3DSurface8_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);