mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
add some more error checking for dds_Lock
This commit is contained in:
parent
55f23e9170
commit
436ffe4ecb
@ -784,8 +784,18 @@ HRESULT dds_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDDSURFACEDES
|
|||||||
|
|
||||||
HRESULT ret = dds_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
HRESULT ret = dds_GetSurfaceDesc(This, lpDDSurfaceDesc);
|
||||||
|
|
||||||
if (lpDestRect && lpDDSurfaceDesc && lpDestRect->left >= 0 && lpDestRect->top >= 0)
|
if (lpDestRect && lpDDSurfaceDesc)
|
||||||
{
|
{
|
||||||
|
if (lpDestRect->left < 0 ||
|
||||||
|
lpDestRect->top < 0 ||
|
||||||
|
lpDestRect->left > lpDestRect->right ||
|
||||||
|
lpDestRect->top > lpDestRect->bottom ||
|
||||||
|
lpDestRect->right > This->width ||
|
||||||
|
lpDestRect->bottom > This->height)
|
||||||
|
{
|
||||||
|
return DDERR_INVALIDPARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
lpDDSurfaceDesc->lpSurface =
|
lpDDSurfaceDesc->lpSurface =
|
||||||
(char*)dds_GetBuffer(This) + (lpDestRect->left * This->lx_pitch) + (lpDestRect->top * This->l_pitch);
|
(char*)dds_GetBuffer(This) + (lpDestRect->left * This->lx_pitch) + (lpDestRect->top * This->l_pitch);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user