Commit d5a98e5d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Fix some memory leaks.

parent 3762de9d
......@@ -2403,20 +2403,32 @@ static HRESULT WINAPI winhttp_request_SetProxy(
{
case HTTPREQUEST_PROXYSETTING_DEFAULT:
request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
heap_free( (WCHAR *)request->proxy.lpszProxy );
heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
request->proxy.lpszProxy = NULL;
request->proxy.lpszProxyBypass = NULL;
break;
case HTTPREQUEST_PROXYSETTING_DIRECT:
request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
heap_free( (WCHAR *)request->proxy.lpszProxy );
heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
request->proxy.lpszProxy = NULL;
request->proxy.lpszProxyBypass = NULL;
break;
case HTTPREQUEST_PROXYSETTING_PROXY:
request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
if (V_VT( &proxy_server ) == VT_BSTR) request->proxy.lpszProxy = strdupW( V_BSTR( &proxy_server ) );
if (V_VT( &bypass_list ) == VT_BSTR) request->proxy.lpszProxyBypass = strdupW( V_BSTR( &bypass_list ) );
if (V_VT( &proxy_server ) == VT_BSTR)
{
heap_free( (WCHAR *)request->proxy.lpszProxy );
request->proxy.lpszProxy = strdupW( V_BSTR( &proxy_server ) );
}
if (V_VT( &bypass_list ) == VT_BSTR)
{
heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
request->proxy.lpszProxyBypass = strdupW( V_BSTR( &bypass_list ) );
}
break;
default:
......@@ -3334,6 +3346,8 @@ HRESULT WinHttpRequest_create( IUnknown *unknown, void **obj )
request->IWinHttpRequest_iface.lpVtbl = &winhttp_request_vtbl;
request->refs = 1;
request->state = REQUEST_STATE_UNINITIALIZED;
request->proxy.lpszProxy = NULL;
request->proxy.lpszProxyBypass = NULL;
InitializeCriticalSection( &request->cs );
*obj = &request->IWinHttpRequest_iface;
......
......@@ -206,6 +206,7 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
session->hdr.flags = flags;
session->hdr.refs = 1;
session->hdr.redirect_policy = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP;
list_init( &session->hdr.children );
session->resolve_timeout = DEFAULT_RESOLVE_TIMEOUT;
session->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
session->send_timeout = DEFAULT_SEND_TIMEOUT;
......@@ -498,6 +499,7 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, LPCWSTR server, INTERNET_PO
connect->hdr.callback = session->hdr.callback;
connect->hdr.notify_mask = session->hdr.notify_mask;
connect->hdr.context = session->hdr.context;
list_init( &connect->hdr.children );
addref_object( &session->hdr );
connect->session = session;
......@@ -505,9 +507,7 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, LPCWSTR server, INTERNET_PO
if (!(connect->hostname = strdupW( server ))) goto end;
connect->hostport = port;
if (!set_server_for_hostname( connect, server, port ))
goto end;
if (!set_server_for_hostname( connect, server, port )) goto end;
if (!(hconnect = alloc_handle( &connect->hdr ))) goto end;
connect->hdr.handle = hconnect;
......@@ -516,7 +516,7 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, LPCWSTR server, INTERNET_PO
end:
release_object( &connect->hdr );
release_object( &session->hdr );
TRACE("returning %p\n", hconnect);
return hconnect;
}
......@@ -930,6 +930,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
request->hdr.callback = connect->hdr.callback;
request->hdr.notify_mask = connect->hdr.notify_mask;
request->hdr.context = connect->hdr.context;
list_init( &request->hdr.children );
addref_object( &connect->hdr );
request->connect = connect;
......@@ -970,7 +971,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
end:
release_object( &request->hdr );
release_object( &connect->hdr );
TRACE("returning %p\n", hrequest);
return hrequest;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment