]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix small memory leak with Console runscripts
authorEric Bollengier <eric@baculasystems.com>
Fri, 23 Nov 2018 09:16:20 +0000 (10:16 +0100)
committerKern Sibbald <kern@sibbald.com>
Thu, 4 Apr 2019 11:12:18 +0000 (07:12 -0400)
bacula/src/lib/runscript.c

index 3aa7af5016c120bb03acdaac86bf0155cbd6eb1d..e5e07fa4b71f998cc628e1b1736b006e5d9d58ed 100644 (file)
@@ -230,7 +230,6 @@ bool RUNSCRIPT::run(JCR *jcr, const char *name)
    switch (cmd_type) {
    case SHELL_CMD:
       bpipe = open_bpipe(ecmd, 0, "r");
-      free_pool_memory(ecmd);
       if (bpipe == NULL) {
          berrno be;
          Jmsg(jcr, M_ERROR, 0, _("Runscript: %s could not execute. ERR=%s\n"), name,
@@ -261,9 +260,11 @@ bool RUNSCRIPT::run(JCR *jcr, const char *name)
       }
       break;
    }
+   free_pool_memory(ecmd);
    return true;
 
 bail_out:
+   free_pool_memory(ecmd);
    /* cancel running job properly */
    if (fail_on_error) {
       jcr->setJobStatus(JS_ErrorTerminated);