1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

add some more error checking for dds_Lock

This commit is contained in:
FunkyFr3sh 2021-05-05 03:02:32 +02:00
parent 55f23e9170
commit 436ffe4ecb

View File

@ -784,8 +784,18 @@ HRESULT dds_Lock(IDirectDrawSurfaceImpl *This, LPRECT lpDestRect, LPDDSURFACEDES
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 =
(char*)dds_GetBuffer(This) + (lpDestRect->left * This->lx_pitch) + (lpDestRect->top * This->l_pitch);
}