Skip to content

Commit 1a113e2

Browse files
committed
OnlineChecks: Fix memory leak
(Fixing world problems for Joe, merry xmas :P)
1 parent c57d233 commit 1a113e2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

plugins/OnlineChecks/virustotal.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,15 @@ PSTR VirusTotalSendHttpRequest(
252252
HINTERNET connectHandle = NULL;
253253
HINTERNET requestHandle = NULL;
254254
PSTR subRequestBuffer = NULL;
255+
PPH_STRING tokenVersion = NULL;
255256
PPH_STRING phVersion = NULL;
256257
PPH_STRING userAgent = NULL;
257258
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = { 0 };
258259

259260
phVersion = PhGetPhVersion();
260261
userAgent = PhConcatStrings2(L"ProcessHacker_", phVersion->Buffer);
262+
tokenVersion = PhConcatStrings2(VIRUSTOTAL_URLPATH, VIRUSTOTAL_APIKEY);
263+
261264
WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig);
262265

263266
if (!(httpSessionHandle = WinHttpOpen(
@@ -293,7 +296,7 @@ PSTR VirusTotalSendHttpRequest(
293296
if (!(requestHandle = WinHttpOpenRequest(
294297
connectHandle,
295298
L"POST",
296-
VIRUSTOTAL_URLPATH VIRUSTOTAL_APIKEY,
299+
tokenVersion->Buffer,
297300
NULL,
298301
WINHTTP_NO_REFERER,
299302
WINHTTP_DEFAULT_ACCEPT_TYPES,
@@ -376,6 +379,9 @@ PSTR VirusTotalSendHttpRequest(
376379
if (httpSessionHandle)
377380
WinHttpCloseHandle(httpSessionHandle);
378381

382+
if (tokenVersion)
383+
PhDereferenceObject(tokenVersion);
384+
379385
return subRequestBuffer;
380386
}
381387

@@ -402,7 +408,7 @@ NTSTATUS NTAPI VirusTotalProcessApiThread(
402408
PSTR jsonArrayToSendString;
403409
PSTR jsonApiResult = NULL;
404410
PVOID jsonArray;
405-
PVOID rootJsonObject;
411+
PVOID rootJsonObject = NULL;
406412
PVOID dataJsonObject;
407413
PPH_LIST resultTempList = NULL;
408414
PPH_LIST virusTotalResults = NULL;
@@ -504,6 +510,11 @@ NTSTATUS NTAPI VirusTotalProcessApiThread(
504510
PhDereferenceObject(virusTotalResults);
505511
}
506512

513+
if (rootJsonObject)
514+
{
515+
CleanupJsonParser(rootJsonObject);
516+
}
517+
507518
if (jsonArray)
508519
{
509520
CleanupJsonParser(jsonArray);

0 commit comments

Comments
 (0)