wined3d: Perform sanity checks on the rectangle in LockRect.

This commit is contained in:
Stefan Dösinger 2006-06-29 21:13:12 +02:00 committed by Alexandre Julliard
parent 2abfc391b4
commit 77448f588b
2 changed files with 22 additions and 0 deletions

View File

@ -348,6 +348,17 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
} else {
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if ((pRect->top < 0) ||
(pRect->left < 0) ||
(pRect->left >= pRect->right) ||
(pRect->top >= pRect->bottom) ||
(pRect->right > This->currentDesc.Width) ||
(pRect->bottom > This->currentDesc.Height))
{
WARN(" Invalid values in pRect !!!\n");
return D3DERR_INVALIDCALL;
}
if (This->resource.format == WINED3DFMT_DXT1) { /* DXT1 is half byte per pixel */
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel / 2));
} else {

View File

@ -196,6 +196,17 @@ IWineGDISurfaceImpl_LockRect(IWineD3DSurface *iface,
TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n",
pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
if ((pRect->top < 0) ||
(pRect->left < 0) ||
(pRect->left >= pRect->right) ||
(pRect->top >= pRect->bottom) ||
(pRect->right > This->currentDesc.Width) ||
(pRect->bottom > This->currentDesc.Height))
{
WARN(" Invalid values in pRect !!!\n");
return D3DERR_INVALIDCALL;
}
if (This->resource.format == WINED3DFMT_DXT1)
{
/* DXT1 is half byte per pixel */