From 77fbbcf30df83acb2ec2a32e06f46820a0d82beb Mon Sep 17 00:00:00 2001 From: Marcus Meissner <marcus@jet.franken.de> Date: Sat, 4 May 2002 18:28:36 +0000 Subject: [PATCH] FindClose: protect the GlobalLock for pagefaults too. --- files/dos_fs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/files/dos_fs.c b/files/dos_fs.c index 0ab59152931..caf49fbd583 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -1806,16 +1806,15 @@ BOOL WINAPI FindClose( HANDLE handle ) { FIND_FIRST_INFO *info; - if ((handle == INVALID_HANDLE_VALUE) || - !(info = (FIND_FIRST_INFO *)GlobalLock( handle ))) - { - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } + if (handle == INVALID_HANDLE_VALUE) goto error; + __TRY { - if (info->dir) DOSFS_CloseDir( info->dir ); - if (info->path) HeapFree( GetProcessHeap(), 0, info->path ); + if ((info = (FIND_FIRST_INFO *)GlobalLock( handle ))) + { + if (info->dir) DOSFS_CloseDir( info->dir ); + if (info->path) HeapFree( GetProcessHeap(), 0, info->path ); + } } __EXCEPT(page_fault) { @@ -1824,9 +1823,14 @@ BOOL WINAPI FindClose( HANDLE handle ) return FALSE; } __ENDTRY + if (!info) goto error; GlobalUnlock( handle ); GlobalFree( handle ); return TRUE; + + error: + SetLastError( ERROR_INVALID_HANDLE ); + return FALSE; } /*********************************************************************** -- GitLab