]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
bpipe: Fix org#2737 About segfault with bpipe
authorEric Bollengier <eric@baculasystems.com>
Wed, 4 Dec 2024 08:06:22 +0000 (09:06 +0100)
committerEric Bollengier <eric@baculasystems.com>
Wed, 4 Dec 2024 08:14:26 +0000 (09:14 +0100)
p_ctx->cmd is allocated with strdup() and released with
smartalloc and it causes the segfault.

Thanks to Marcin for this report.

bacula/src/plugins/fd/bpipe-fd.c

index 665a236715d3f6bed5e32901b394361dc70dcdb0..a1296fbd07ffb436885ceb0f68882c027b189aa5 100644 (file)
@@ -202,7 +202,9 @@ static bRC freePlugin(bpContext *ctx)
    if (!p_ctx) {
       return bRC_Error;
    }
-   bfree_and_null(p_ctx->cmd);
+   if (p_ctx->cmd) {
+      free(p_ctx->cmd);                  /* free any allocated command string */
+   }
    free_and_null_pool_memory(p_ctx->restore_obj_buf);
    if (p_ctx->rop_writer) {
       restoreobj *rop;