[PATCH] Object large handle invalid value

Gerard Patel gerard.patel at nerim.net
Sat Aug 18 11:37:06 CDT 2001


Catch invalid values passed as large handles (triggered by a Wine problem
in filedlg95.c, addressed in next patch)

    ChangeLog:

	* objects/gdiobj.c
               test for invalid large handles in GDI_GetObjPtr and
GDI_FreeObject

-------------- next part --------------
Index: objects/gdiobj.c
===================================================================
RCS file: /home/wine/wine/objects/gdiobj.c,v
retrieving revision 1.55
diff -u -r1.55 gdiobj.c
--- objects/gdiobj.c	2001/08/17 00:07:14	1.55
+++ objects/gdiobj.c	2001/08/18 13:13:53
@@ -320,7 +320,9 @@
     else  /* large heap handle */
     {
         int i = (handle >> 2) - FIRST_LARGE_HANDLE;
-        if (i >= 0 && large_handles[i])
+        if (i >= MAX_LARGE_HANDLES)
+            ERR("Invalid handle %x\n", handle);
+        else if (i >= 0 && large_handles[i])
         {
             HeapFree( GetProcessHeap(), 0, large_handles[i] );
             large_handles[i] = NULL;
@@ -357,7 +359,9 @@
     else  /* large heap handle */
     {
         int i = (handle >> 2) - FIRST_LARGE_HANDLE;
-        if (i >= 0)
+        if (i >= MAX_LARGE_HANDLES)
+            ERR("Invalid handle %x\n", handle);
+        else if (i >= 0)
         {
             ptr = large_handles[i];
             if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
-------------- next part --------------



More information about the wine-patches mailing list