From b81e96eb2a74b367a95c18df4152d854a46fb8c7 Mon Sep 17 00:00:00 2001
From: Ivan de Saedeleer <Ivands@sympatico.ca>
Date: Sun, 31 Oct 1999 21:32:42 +0000
Subject: [PATCH] Fail when LPRECT contains negative values.

---
 graphics/ddraw.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/graphics/ddraw.c b/graphics/ddraw.c
index 75a75553b2a..da0bd41e3bb 100644
--- a/graphics/ddraw.c
+++ b/graphics/ddraw.c
@@ -1014,6 +1014,13 @@ static HRESULT WINAPI IDirectDrawSurface4Impl_Blt(
   }
   
   if (rdst) {
+    if ((rdst->top < 0) ||
+        (rdst->left < 0) ||
+        (rdst->bottom < 0) ||
+        (rdst->right < 0)) {
+      ERR(" Negative values in LPRECT !!!\n");
+      goto release;
+    }
     memcpy(&xdst,rdst,sizeof(xdst));
   } else {
     xdst.top	= 0;
@@ -1023,6 +1030,13 @@ static HRESULT WINAPI IDirectDrawSurface4Impl_Blt(
   }
   
   if (rsrc) {
+    if ((rsrc->top < 0) ||
+        (rsrc->left < 0) ||
+        (rsrc->bottom < 0) ||
+        (rsrc->right < 0)) {
+      ERR(" Negative values in LPRECT !!!\n");
+      goto release;
+    }
     memcpy(&xsrc,rsrc,sizeof(xsrc));
   } else {
     if (src) {
@@ -1204,6 +1218,7 @@ static HRESULT WINAPI IDirectDrawSurface4Impl_Blt(
     FIXME("\tUnsupported flags: ");
     _dump_DDBLT(dwFlags);
   }
+  release:
   
   IDirectDrawSurface4_Unlock(iface,ddesc.u1.lpSurface);
   if (src) IDirectDrawSurface4_Unlock(src,sdesc.u1.lpSurface);
-- 
GitLab