Henri Verbeet : d3d8: Clear pBits and Pitch when d3d8_surface_LockRect() fails.
Alexandre Julliard
julliard at winehq.org
Tue Nov 12 14:26:37 CST 2013
Module: wine
Branch: master
Commit: b83a0b9d3ee88b5a09700bc3a25d3ae3a49aa84f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b83a0b9d3ee88b5a09700bc3a25d3ae3a49aa84f
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Nov 12 11:00:25 2013 +0100
d3d8: Clear pBits and Pitch when d3d8_surface_LockRect() fails.
This is a only slightly modified version of a patch by Lasse Rasinen.
---
dlls/d3d8/surface.c | 12 ++++++++++--
dlls/d3d8/tests/device.c | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index a157c51..0b40c46 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -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;
}
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index a0fcd71..f5afbc4 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -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);
More information about the wine-cvs
mailing list