Fix two handle leaks during remote probe

Added logic to the entry point RENDERDOC_CreateRemoteServerConnection to shutdown the socket used to connect to a remote device when the function is used to test a connection (IRemoteServer **rend is null.) This previously created a handle leak, visible as accumulating /device/afd/ file handles on Windows.

Added logic to the Windows specialization of Process::LaunchProcess so it will close two handles: hChildStdError_Rd, and hChildStdOutput_Rd if the handles were created successfully but the process failed to launch. Previously these would accumulate during a remote probe for Android devices if ADB was not present or otherwise failed to launch.
This commit is contained in:
james-sumihiro
2024-01-12 16:53:01 -08:00
committed by Baldur Karlsson
parent 4409e57919
commit 783d76fe73
2 changed files with 9 additions and 0 deletions
+3
View File
@@ -1247,7 +1247,10 @@ RENDERDOC_CreateRemoteServerConnection(const rdcstr &URL, IRemoteServer **rend)
}
if(rend == NULL)
{
SAFE_DELETE(sock);
return RDResult(ResultCode::Succeeded);
}
if(protocol)
*rend = protocol->CreateRemoteServer(sock, deviceID);
+6
View File
@@ -1060,6 +1060,12 @@ uint32_t Process::LaunchProcess(const rdcstr &app, const rdcstr &workingDir, con
{
if(!internal)
RDCWARN("Couldn't launch process '%s'", appPath.c_str());
if(hChildStdError_Rd != NULL)
CloseHandle(hChildStdError_Rd);
if(hChildStdOutput_Rd != NULL)
CloseHandle(hChildStdOutput_Rd);
return 0;
}