[D3D] Better invalid RECT check

Lionel Ulmer lionel.ulmer at free.fr
Sat Jun 7 16:25:49 CDT 2003


Finally, no need for ugly hacks to get DungeonSiege to work properly. One
has just to check properly for the RECT given to us in the Lock function :-)

Changelog:
 - be more stringent in the 'Lock' invalid RECT check

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- dlls/ddraw_CVS/dsurface/main.c	Fri Jun  6 21:24:12 2003
+++ dlls/ddraw/dsurface/main.c	Sat Jun  7 23:21:49 2003
@@ -1016,11 +1016,19 @@
     if (prect != NULL) {
 	TRACE("	lprect: %ldx%ld-%ldx%ld\n",
 		prect->top,prect->left,prect->bottom,prect->right);
+	/* First do some sanity checkings on the rectangle we receive.
+	   DungeonSiege seems to gives us once a very bad rectangle for example */
 	if ((prect->top < 0) ||
 	    (prect->left < 0) ||
 	    (prect->bottom < 0) ||
-	    (prect->right < 0)) {
-	    ERR(" Negative values in LPRECT !!!\n");
+	    (prect->right < 0) ||
+	    (prect->left >= prect->right) ||
+	    (prect->top >= prect->bottom) ||
+	    (prect->left >= This->surface_desc.dwWidth) ||
+	    (prect->right > This->surface_desc.dwWidth) ||
+	    (prect->top >= This->surface_desc.dwHeight) ||
+	    (prect->bottom > This->surface_desc.dwHeight)) {
+	    ERR(" Invalid values in LPRECT !!!\n");
 	    return DDERR_INVALIDPARAMS;
 	}
 


More information about the wine-patches mailing list