Skip to content

Commit

Permalink
Fix two handle leaks during remote probe
Browse files Browse the repository at this point in the history
 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.
  • Loading branch information
james-sumihiro authored and baldurk committed Jan 15, 2024
1 parent 4409e57 commit 783d76f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions renderdoc/core/remote_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions renderdoc/os/win32/win32_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 783d76f

Please sign in to comment.