Module: wine Branch: master Commit: 705b01c05479cb931e0e2a3bc5984425ff602721 URL: http://source.winehq.org/git/wine.git/?a=commit;h=705b01c05479cb931e0e2a3bc5...
Author: Misha Koshelev mk144210@bcm.edu Date: Fri Sep 21 21:27:48 2007 -0500
wininet: When sending INTERNET_STATUS_HANDLE_CLOSING make sure the freed handle is not yet available.
---
dlls/wininet/internet.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 5e95a12..0edca74 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -208,13 +208,14 @@ BOOL WININET_FreeHandle( HINTERNET hinternet ) TRACE( "destroying handle %d for object %p\n", handle+1, info); WININET_Handles[handle] = NULL; ret = TRUE; - if( WININET_dwNextHandle > handle ) - WININET_dwNextHandle = handle; } }
LeaveCriticalSection( &WININET_cs );
+ /* As on native when the equivalent of WININET_Release is called, the handle + * is already invalid, but if a new handle is created at this time it does + * not yet get assigned the freed handle number */ if( info ) { /* Free all children as native does */ @@ -227,6 +228,13 @@ BOOL WININET_FreeHandle( HINTERNET hinternet ) WININET_Release( info ); }
+ EnterCriticalSection( &WININET_cs ); + + if( WININET_dwNextHandle > handle && !WININET_Handles[handle] ) + WININET_dwNextHandle = handle; + + LeaveCriticalSection( &WININET_cs ); + return ret; }
@@ -1006,8 +1014,8 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet) return FALSE; }
- WININET_FreeHandle( hInternet ); WININET_Release( lpwh ); + WININET_FreeHandle( hInternet );
return TRUE; }