From 17ddfd150ff1d84021342ee82ff53b5860579252 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 18 Feb 2013 18:38:50 +0200 Subject: [PATCH] Avoid leaking handles on MS-Windows. src/w32proc.c (new_child): Avoid leaking handles if the subprocess resources were not orderly released. --- src/ChangeLog | 5 +++++ src/w32proc.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 4325d35ade..99b5e8734e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-02-18 Eli Zaretskii + + * w32proc.c (new_child): Avoid leaking handles if the subprocess + resources were not orderly released. + 2013-02-17 Eli Zaretskii * w32proc.c (new_child): Remove the loop that attempted to salvage diff --git a/src/w32proc.c b/src/w32proc.c index 3b4522bf16..da4549bd7d 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -802,6 +802,12 @@ new_child (void) cp = &child_procs[child_proc_count++]; Initialize: + /* Last opportunity to avoid leaking handles before we forget them + for good. */ + if (cp->procinfo.hProcess) + CloseHandle (cp->procinfo.hProcess); + if (cp->procinfo.hThread) + CloseHandle (cp->procinfo.hThread); memset (cp, 0, sizeof (*cp)); cp->fd = -1; cp->pid = -1; -- 2.20.1