OnlineChecks: Fix service right-click crash
@@ -346,15 +346,24 @@ VOID NTAPI ServiceMenuInitializingCallback(
else
serviceItem = NULL;
+ if (serviceItem)
+ {
QueryServiceFileName(
&serviceItem->Name->sr,
&serviceFileName,
&serviceBinaryPath
);
+ }
- if (serviceBinaryPath) PhDereferenceObject(serviceBinaryPath);
+ if (serviceBinaryPath)
+ PhDereferenceObject(serviceBinaryPath);
+
+ if (serviceFileName)
+ {
+ // TODO: memory leak or possible use-after-free bug?
+ PhAutoDereferenceObject(serviceFileName);
+ }
- // TODO: Possible serviceFileName string memory leak.
sendToMenu = CreateSendToMenu(menuInfo->Menu, serviceFileName ? serviceFileName : NULL);
if (!serviceItem || !serviceFileName)
