[02/02] d3d8: update locked_rect only if wined3d_surface_map succeeds
Lasse Rasinen
lrasinen at iki.fi
Mon Oct 21 03:47:18 CDT 2013
For completeness.
---
dlls/d3d8/surface.c | 7 +++++--
dlls/d3d8/tests/device.c | 4 ++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index a157c51..d68c127 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -273,8 +273,11 @@ 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;
+ }
return hr;
}
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 7932a7f..52cf27a 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -4022,8 +4022,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 = 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 == 0xdeadbeef, "pBits changed on double lock.\n");
+ ok(locked_rect.Pitch == 1, "Pitch changed on double lock.\n");
hr = IDirect3DSurface8_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
--
1.7.12.4 (Apple Git-37)
--
Lasse Rasinen
lrasinen at iki.fi
More information about the wine-patches
mailing list