d3d9: update locked_rect only if wined3d_surface_map succeeded

Lasse Rasinen lrasinen at iki.fi
Thu Oct 3 14:16:46 CDT 2013


According to debugging output, Artemis Spaceship Bridge Simulator 2.0
calls LockRect twice on the same texture (for whatever reason) and crashes.

http://bugs.winehq.org/show_bug.cgi?id=34271

This change prevents the locked_rect being overwritten with garbage in
that case, and the game no longer crashes.

---
 dlls/d3d9/surface.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 99f0b0f..8b7cea7 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -293,8 +293,10 @@ 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 (hr == WINED3D_OK) {
+        locked_rect->Pitch = map_desc.row_pitch;
+        locked_rect->pBits = map_desc.data;
+    }
 
     return hr;
 }


-- 
Lasse Rasinen
lrasinen at iki.fi



More information about the wine-patches mailing list