ctdb-common: Fix memory leak in run_proc
authorAmitay Isaacs <amitay@gmail.com>
Mon, 13 May 2019 07:07:59 +0000 (17:07 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 14 May 2019 08:59:03 +0000 (08:59 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13943

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue May 14 08:59:03 UTC 2019 on sn-devel-184

ctdb/common/run_proc.c

index 037b6d9651de358035a6dbc04494e99549420f7e..0c3c1de72fe0144cd407136ff1d56ec96fb13746 100644 (file)
@@ -302,13 +302,15 @@ again:
                proc->fd = -1;
        }
 
+       DLIST_REMOVE(run_ctx->plist, proc);
+
        /* Active run_proc request */
        if (proc->req != NULL) {
                run_proc_done(proc->req);
+       } else {
+               talloc_free(proc);
        }
 
-       DLIST_REMOVE(run_ctx->plist, proc);
-
        goto again;
 }
 
@@ -426,6 +428,7 @@ static void run_proc_done(struct tevent_req *req)
        if (state->proc->output != NULL) {
                state->output = talloc_steal(state, state->proc->output);
        }
+       talloc_steal(state, state->proc);
 
        tevent_req_done(req);
 }