Illegal handles in FindClose [Resend]

Dominik Strasser dominik.strasser at mchp.siemens.de
Thu Apr 19 09:12:23 CDT 2001


The application I am trying to make runnable passes an illegal handle to
FindClose. It is 0xcccccccc which is an unitialized stack address (at
least I remember to have seen those when I was doing Windoze programs).
I wrapped the access into an exception handler.

Alexandre:
Why didn't you apply this patch even after I resent you a diff -u ?
Is there anything wrong with it ?

ChangeLog:
        * files/dos_fs.c
        Dominik Strasser <dominik.strasser at mchp.siemens.de>
        Allow illegal handles in FindClose

-- 
Dominik Strasser	| Phone:  +49 89 636-43691
SIEMENS AG		| Fax:    +49 89 636-42284
CT SE 4			| E-Mail:Dominik.Strasser at mchp.siemens.de
Otto-Hahn-Ring 6	|
D-81739 Muenchen	| Room: 53-263
-------------- next part --------------
--- dos_fs.c	Thu Apr 19 15:56:38 2001
+++ dos_fs.c.new	Tue Mar  6 09:06:12 2001
@@ -105,6 +105,13 @@
 } FIND_FIRST_INFO;
 
 
+static WINE_EXCEPTION_FILTER(page_fault)
+{
+    if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
+        return EXCEPTION_EXECUTE_HANDLER;
+    return EXCEPTION_CONTINUE_SEARCH;
+}
+
 
 /***********************************************************************
  *           DOSFS_ValidDOSName
@@ -1768,8 +1775,18 @@
         SetLastError( ERROR_INVALID_HANDLE );
         return FALSE;
     }
-    if (info->dir) DOSFS_CloseDir( info->dir );
-    if (info->path) HeapFree( GetProcessHeap(), 0, info->path );
+	__TRY
+	{
+		if (info->dir) DOSFS_CloseDir( info->dir );
+		if (info->path) HeapFree( GetProcessHeap(), 0, info->path );
+	}
+	__EXCEPT(page_fault)
+	{
+		WARN("Illegal handle %x\n", info);
+		SetLastError( ERROR_INVALID_HANDLE );
+		return FALSE;
+	}
+	__ENDTRY
     GlobalUnlock( handle );
     GlobalFree( handle );
     return TRUE;


More information about the wine-patches mailing list