Skip to content

Commit 92f1821

Browse files
committed
Clean up memory after call to WinHttpGetIEProxyConfigForCurrentUser
1 parent 11fd953 commit 92f1821

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Release/src/http/client/http_client_winhttp.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,25 @@ class winhttp_client : public _http_client_communicator
385385
}
386386
else
387387
{
388-
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyInfo;
388+
struct raii_ie_proxy_config : WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
389+
{
390+
raii_ie_proxy_config()
391+
{
392+
memset(this, 0, sizeof(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG));
393+
}
394+
395+
~raii_ie_proxy_config()
396+
{
397+
if (lpszProxy)
398+
::GlobalFree(lpszProxy);
399+
if (lpszProxyBypass)
400+
::GlobalFree(lpszProxyBypass);
401+
if (lpszAutoConfigUrl)
402+
::GlobalFree(lpszAutoConfigUrl);
403+
}
404+
};
405+
406+
raii_ie_proxy_config proxyInfo;
389407
BOOL result = WinHttpGetIEProxyConfigForCurrentUser(&proxyInfo);
390408
if (result && proxyInfo.lpszProxy != nullptr)
391409
{

0 commit comments

Comments
 (0)