File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,24 @@ static DWORD ChooseAuthScheme( DWORD dwSupportedSchemes )
297297 return 0 ;
298298}
299299
300+ // Small RAII helper to ensure that the fields of this struct are always
301+ // properly freed.
302+ struct proxy_info : WINHTTP_PROXY_INFO
303+ {
304+ proxy_info ()
305+ {
306+ memset ( this , 0 , sizeof (WINHTTP_PROXY_INFO) );
307+ }
308+
309+ ~proxy_info ()
310+ {
311+ if ( lpszProxy )
312+ ::GlobalFree (lpszProxy);
313+ if ( lpszProxyBypass )
314+ ::GlobalFree (lpszProxyBypass);
315+ }
316+ };
317+
300318// WinHTTP client.
301319class winhttp_client : public _http_client_communicator
302320{
@@ -494,14 +512,13 @@ class winhttp_client : public _http_client_communicator
494512 http_request &msg = request->m_request ;
495513 winhttp_request_context * winhttp_context = static_cast <winhttp_request_context *>(request.get ());
496514
497- WINHTTP_PROXY_INFO info;
515+ proxy_info info;
498516 bool proxy_info_required = false ;
499517
500518 if ( client_config ().proxy ().is_auto_discovery () )
501519 {
502520 WINHTTP_AUTOPROXY_OPTIONS autoproxy_options;
503521 memset ( &autoproxy_options, 0 , sizeof (WINHTTP_AUTOPROXY_OPTIONS) );
504- memset ( &info, 0 , sizeof (WINHTTP_PROXY_INFO) );
505522
506523 autoproxy_options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
507524 autoproxy_options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
You can’t perform that action at this time.
0 commit comments