Commit a2d3b3a5 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d8: Don't validate 2D texture lock coordinates.

parent b23ab91e
...@@ -204,26 +204,36 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, ...@@ -204,26 +204,36 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
struct wined3d_box box; struct wined3d_box box;
struct wined3d_map_desc map_desc; struct wined3d_map_desc map_desc;
HRESULT hr; HRESULT hr;
D3DRESOURCETYPE type;
TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n", TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
iface, locked_rect, wine_dbgstr_rect(rect), flags); iface, locked_rect, wine_dbgstr_rect(rect), flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
if (surface->texture)
type = IDirect3DBaseTexture8_GetType(&surface->texture->IDirect3DBaseTexture8_iface);
else
type = D3DRTYPE_SURFACE;
if (rect) if (rect)
{ {
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
IDirect3DSurface8_GetDesc(iface, &desc); IDirect3DSurface8_GetDesc(iface, &desc);
if ((rect->left < 0) if (type != D3DRTYPE_TEXTURE
&& ((rect->left < 0)
|| (rect->top < 0) || (rect->top < 0)
|| (rect->left >= rect->right) || (rect->left >= rect->right)
|| (rect->top >= rect->bottom) || (rect->top >= rect->bottom)
|| (rect->right > desc.Width) || (rect->right > desc.Width)
|| (rect->bottom > desc.Height)) || (rect->bottom > desc.Height)))
{ {
WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n"); WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
wined3d_mutex_unlock(); wined3d_mutex_unlock();
locked_rect->Pitch = 0;
locked_rect->pBits = NULL;
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
box.left = rect->left; box.left = rect->left;
...@@ -243,7 +253,7 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, ...@@ -243,7 +253,7 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
locked_rect->Pitch = map_desc.row_pitch; locked_rect->Pitch = map_desc.row_pitch;
locked_rect->pBits = map_desc.data; locked_rect->pBits = map_desc.data;
} }
else else if (type != D3DRTYPE_TEXTURE)
{ {
locked_rect->Pitch = 0; locked_rect->Pitch = 0;
locked_rect->pBits = NULL; locked_rect->pBits = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment