[WININET] Fix callback calling in asynchronous mode.

Lionel Ulmer lionel.ulmer at free.fr
Wed Dec 22 13:55:40 CST 2004


Hi,

Even if I am still not convinced that the callback should ever be called
'asynchronously' from the working thread (i.e. that the working thread
should let another working thread do the work of calling the callback), the
code doing this was still buggy as it could potentially send a stack-local
variable through the request.

    Lionel

Changelog:
  Fix 'SendAsyncCallback' when it's really asynchronous

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
diff -ur ../wine_base/dlls/wininet/internet.c dlls/wininet/internet.c
--- ../wine_base/dlls/wininet/internet.c	2004-12-22 20:48:45.896303264 +0100
+++ dlls/wininet/internet.c	2004-12-22 20:48:30.841591928 +0100
@@ -2744,8 +2744,11 @@
         TRACE("SENDCALLBACK %p\n", workRequest.hdr);
 
         SendSyncCallback(workRequest.hdr,
-                req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
-                req->dwStatusInfoLength);
+			 req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
+			 req->dwStatusInfoLength);
+	
+	/* And frees the copy of the status info */
+	HeapFree(GetProcessHeap(), 0, req->lpvStatusInfo);
         }
         break;
 
diff -ur ../wine_base/dlls/wininet/utility.c dlls/wininet/utility.c
--- ../wine_base/dlls/wininet/utility.c	2004-12-22 20:48:45.899302808 +0100
+++ dlls/wininet/utility.c	2004-12-22 20:46:34.248316800 +0100
@@ -276,13 +276,20 @@
     {
 	WORKREQUEST workRequest;
 	struct WORKREQ_SENDCALLBACK *req;
-	
+	void *lpvStatusInfo_copy = lpvStatusInfo;
+
+	if (lpvStatusInfo)
+	{
+	    lpvStatusInfo_copy = HeapAlloc(GetProcessHeap(), 0, dwStatusInfoLength);
+	    memcpy(lpvStatusInfo_copy, lpvStatusInfo, dwStatusInfoLength);
+	}
+
 	workRequest.asyncall = SENDCALLBACK;
 	workRequest.hdr = WININET_AddRef( hdr );
 	req = &workRequest.u.SendCallback;
 	req->dwContext = dwContext;
 	req->dwInternetStatus = dwInternetStatus;
-	req->lpvStatusInfo = lpvStatusInfo;
+	req->lpvStatusInfo = lpvStatusInfo_copy;
 	req->dwStatusInfoLength = dwStatusInfoLength;
 	
 	INTERNET_AsyncCall(&workRequest);


More information about the wine-patches mailing list