BUG#: 8134
authorkumpf <kumpf>
Mon, 17 Nov 2008 19:24:12 +0000 (19:24 +0000)
committerkumpf <kumpf>
Mon, 17 Nov 2008 19:24:12 +0000 (19:24 +0000)
TITLE: Executor leaks pipe handles on error
DESCRIPTION: Correct the pipe handle clean-up logic on error conditions.

src/Executor/Parent.c

index 2358f5a73dace35e19236acc1ed41f16bbc94553..2893e82799a9ee9903cc60b7a2d9c491aef09829 100644 (file)
@@ -322,6 +322,8 @@ static void HandleStartProviderAgentRequest(int sock)
 
         if (pipe(from) != 0)
         {
+            close(to[0]);
+            close(to[1]);
             status = -1;
             break;
         }
@@ -333,6 +335,10 @@ static void HandleStartProviderAgentRequest(int sock)
         if (pid < 0)
         {
             Log(LL_SEVERE, "fork failed");
+            close(to[0]);
+            close(to[1]);
+            close(from[0]);
+            close(from[1]);
             status = -1;
             break;
         }
@@ -409,13 +415,13 @@ static void HandleStartProviderAgentRequest(int sock)
                 request.module);
             _exit(1);
         }
-    }
-    while (0);
 
-    /* Close unused pipe descriptors. */
+        /* We are the parent process.  Close the child's ends of the pipes. */
 
-    close(to[0]);
-    close(from[1]);
+        close(to[0]);
+        close(from[1]);
+    }
+    while (0);
 
     /* Send response. */