winhttp: Properly free all allocated memory on error in WinHttpOpen
Bruno Jesus
00cpxxx at gmail.com
Mon Jun 16 16:38:08 CDT 2014
Found while checking bug https://bugs.winehq.org/show_bug.cgi?id=36600
-------------- next part --------------
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 56e776d..81fda27 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -241,13 +241,8 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
WinHttpGetDefaultProxyConfiguration( &info );
session->access = info.dwAccessType;
- if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
- {
- GlobalFree( info.lpszProxy );
- GlobalFree( info.lpszProxyBypass );
- goto end;
- }
- if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
+ if ((info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy ))) ||
+ (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass ))))
{
GlobalFree( info.lpszProxy );
GlobalFree( info.lpszProxyBypass );
@@ -264,10 +259,13 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
if (!(handle = alloc_handle( &session->hdr ))) goto end;
session->hdr.handle = handle;
-end:
release_object( &session->hdr );
TRACE("returning %p\n", handle);
return handle;
+end:
+ session_destroy( &session->hdr );
+ TRACE("returning (null)\n");
+ return NULL;
}
/***********************************************************************
More information about the wine-patches
mailing list