]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Fix CID 1125627 Resource leak (RESOURCE_LEAK)
authorMartin Schwenke <martin@meltin.net>
Fri, 5 Aug 2016 06:50:58 +0000 (16:50 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 8 Aug 2016 06:17:34 +0000 (08:17 +0200)
Also fixes CID 1125628.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_logging.c

index 168d3b55569b849cd52440fdc00f02a3d44ae8bb..692df73b1b74ffbdfdfeee939f8fbc8ab91f29fc 100644 (file)
@@ -282,9 +282,14 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
 
        /* We'll fail if stderr/stdout not already open; it's simpler. */
        old_stdout = dup(STDOUT_FILENO);
+       if (old_stdout < 0) {
+               DEBUG(DEBUG_ERR, ("Failed to dup stdout for child logging\n"));
+               return -1;
+       }
        old_stderr = dup(STDERR_FILENO);
-       if (old_stdout < 0 || old_stderr < 0) {
-               DEBUG(DEBUG_ERR, ("Failed to dup stdout/stderr for child logging\n"));
+       if (old_stderr < 0) {
+               DEBUG(DEBUG_ERR, ("Failed to dup stderr for child logging\n"));
+               close(old_stdout);
                return -1;
        }
        if (dup2(p[1], STDOUT_FILENO) < 0 || dup2(p[1], STDERR_FILENO) < 0) {