wsutil: Fix pipe handle leaks on Windows

If the PATHEXT environment variable contains .py and extcap is enabled,
then Wireshark did leak 2 pipes for every .py file present in the extcap
directory (regardless if there was .bat wrapper for it or not).

Bug: 15689
Change-Id: Iae402c0075ee8155a7205a59711bbae734da7e9e
Reviewed-on: https://code.wireshark.org/review/32812
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Tomasz Moń 2019-04-10 18:19:18 +02:00 committed by Guy Harris
parent 3e6af782d5
commit b95933a031
1 changed files with 11 additions and 0 deletions

View File

@ -283,7 +283,14 @@ gboolean ws_pipe_spawn_sync(const gchar *working_directory, const gchar *command
CloseHandle(processInfo.hThread);
}
else
{
status = FALSE;
CloseHandle(child_stdout_rd);
CloseHandle(child_stdout_wr);
CloseHandle(child_stderr_rd);
CloseHandle(child_stderr_wr);
}
#else
GSpawnFlags flags = (GSpawnFlags)0;
@ -358,12 +365,16 @@ GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args)
if (!CreatePipe(&child_stdout_rd, &child_stdout_wr, &sa, 0))
{
CloseHandle(child_stdin_rd);
CloseHandle(child_stdin_wr);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Could not create stdout handle");
return FALSE;
}
if (!CreatePipe(&child_stderr_rd, &child_stderr_wr, &sa, 0))
{
CloseHandle(child_stdin_rd);
CloseHandle(child_stdin_wr);
CloseHandle(child_stdout_rd);
CloseHandle(child_stdout_wr);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Could not create stderr handle");