CloseHandle with 0xffffffff parameter

Marcus Meissner marcus at jet.franken.de
Wed Aug 1 06:57:04 CDT 2001


...
> > -   if (hMap) CloseHandle(hMap);
> > -   if (hFile) CloseHandle(hFile);
> > +   if (hMap!=INVALID_HANDLE_VALUE) CloseHandle(hMap);
> > +   if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile);
> 
> I don't want to appear dump, but shouldn't you check for hMap != 0 and
> hFile != 0?

*sigh*

There is a syntactic difference between handles for files and
mappings apparently.

While CreateFileMapping can give back 0, CreateFile does not.
I fixed the initialisation too, so it should work better now.

Ciao, Marcus

Changelog:
 	Check for -1 as the undefined value for handles before CloseHandle.

Index: msc.c
===================================================================
RCS file: /home/wine/wine/debugger/msc.c,v
retrieving revision 1.41
diff -u -r1.41 msc.c
--- msc.c	2001/07/23 00:04:00	1.41
+++ msc.c	2001/08/01 12:03:45
@@ -120,7 +120,7 @@
 {
    if (addr) UnmapViewOfFile(addr);
    if (hMap) CloseHandle(hMap);
-   if (hFile) CloseHandle(hFile);
+   if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile);
 }
 
 
@@ -2898,7 +2898,7 @@
 					      const char *filename, DWORD timestamp )
 {
     enum DbgInfoLoad dil = DIL_ERROR;
-    HANDLE hFile = 0, hMap = 0;
+    HANDLE hFile = INVALID_HANDLE_VALUE, hMap = 0;
     LPBYTE file_map = NULL;
     PIMAGE_SEPARATE_DEBUG_HEADER hdr;
     PIMAGE_DEBUG_DIRECTORY dbg; 




More information about the wine-patches mailing list