Wininet: Don't Crash on Double InternetCloseHandle

Robert Shearman rob at codeweavers.com
Thu Sep 23 07:40:05 CDT 2004


Changelog:
- Don't crash on double InternetCloseHandle.
- Test case for this.
-------------- next part --------------
Index: wine/dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.99
diff -u -p -r1.99 internet.c
--- wine/dlls/wininet/internet.c	20 Sep 2004 19:10:31 -0000	1.99
+++ wine/dlls/wininet/internet.c	23 Sep 2004 10:55:35 -0000
@@ -192,7 +192,8 @@ LPWININETHANDLEHEADER WININET_GetObject(
 
     EnterCriticalSection( &WININET_cs );
 
-    if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
+    if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) && 
+        WININET_Handles[handle-1] )
         info = WININET_AddRef( WININET_Handles[handle-1] );
 
     LeaveCriticalSection( &WININET_cs );
Index: wine/dlls/wininet/tests/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/tests/http.c,v
retrieving revision 1.14
diff -u -p -r1.14 http.c
--- wine/dlls/wininet/tests/http.c	6 Aug 2004 18:58:04 -0000	1.14
+++ wine/dlls/wininet/tests/http.c	23 Sep 2004 10:55:35 -0000
@@ -195,6 +195,8 @@ abort:
     if (hor != 0x0) {
         rc = InternetCloseHandle(hor);
         ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
+        rc = InternetCloseHandle(hor);
+        ok ((rc == 0), "Double close of handle opened by HttpOpenRequestA succeeded\n");
     }
     if (hic != 0x0) {
         rc = InternetCloseHandle(hic);


More information about the wine-patches mailing list