[PATCH] wininet: Release object in HttpSendRequestExW before return on error

Nigel Liang ncliang at gmail.com
Sat Nov 3 20:24:49 CDT 2007


Hi,

This patch makes sure the request object is freed before returning.

-Nigel

---
 dlls/wininet/http.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 53d6fba..a316fa4 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2121,7 +2121,7 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET
                    LPINTERNET_BUFFERSW lpBuffersOut,
                    DWORD dwFlags, DWORD_PTR dwContext)
 {
-    BOOL ret;
+    BOOL ret = FALSE;
     LPWININETHTTPREQW lpwhr;
     LPWININETHTTPSESSIONW lpwhs;
     LPWININETAPPINFOW hIC;
@@ -2134,7 +2134,7 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET
     if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
-    	return FALSE;
+        goto lend;
     }
 
     lpwhs = lpwhr->lpHttpSession;
@@ -2178,7 +2178,6 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET
          * This is from windows.
          */
         INTERNET_SetLastError(ERROR_IO_PENDING);
-        ret = FALSE;
     }
     else
     {
@@ -2189,8 +2188,11 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET
         else
             ret = HTTP_HttpSendRequestW(lpwhr, NULL, 0, NULL, 0, 0, FALSE);
     }
- 
-    WININET_Release(&lpwhr->hdr);
+
+lend:
+    if ( lpwhr )
+        WININET_Release( &lpwhr->hdr );
+
     TRACE("<---\n");
     return ret;
 }
-- 
1.4.1




More information about the wine-patches mailing list