Lasse Rasinen : d3d9: Update locked_rect only if wined3d_surface_map succeeds.

Alexandre Julliard julliard at winehq.org
Mon Oct 28 15:13:05 CDT 2013


Module: wine
Branch: master
Commit: eeefed3dd02f5299e38d308ee6d9ba6998722bdd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eeefed3dd02f5299e38d308ee6d9ba6998722bdd

Author: Lasse Rasinen <lrasinen at iki.fi>
Date:   Mon Oct 28 18:48:17 2013 +0200

d3d9: Update locked_rect only if wined3d_surface_map succeeds.

---

 dlls/d3d9/surface.c      |    7 +++++--
 dlls/d3d9/tests/device.c |    5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 99f0b0f..d475ae4 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -293,8 +293,11 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *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;
+    }
 
     return hr;
 }
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 32fe8c7..37fb8fe 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -5402,8 +5402,13 @@ static void test_lockrect_invalid(void)
 
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
     ok(SUCCEEDED(hr), "Failed to lock surface with rect NULL, hr %#x.\n", hr);
+    locked_rect.pBits = (BYTE *)0xdeadbeef;
+    locked_rect.Pitch = 1;
     hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(locked_rect.pBits == (BYTE *)0xdeadbeef, "Got unexpected pBits: %p\n",
+            locked_rect.pBits);
+    ok(locked_rect.Pitch == 1, "Got unexpected pitch %d\n", locked_rect.Pitch);
     hr = IDirect3DSurface9_UnlockRect(surface);
     ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
 




More information about the wine-cvs mailing list