Avoid leaking handles on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 18 Feb 2013 16:38:50 +0000 (18:38 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 18 Feb 2013 16:38:50 +0000 (18:38 +0200)
 src/w32proc.c (new_child): Avoid leaking handles if the subprocess
 resources were not orderly released.

src/ChangeLog
src/w32proc.c

index 4325d35..99b5e87 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-18  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32proc.c (new_child): Avoid leaking handles if the subprocess
+       resources were not orderly released.
+
 2013-02-17  Eli Zaretskii  <eliz@gnu.org>
 
        * w32proc.c (new_child): Remove the loop that attempted to salvage
index 3b4522b..da4549b 100644 (file)
@@ -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;