From: Eric Bollengier Date: Fri, 19 Nov 2021 21:22:22 +0000 (+0100) Subject: Fix memory leak when restore is aborted X-Git-Tag: Beta-15.0.0~755 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d9e1fe99b31110e038b4f1e7e100088aac1989f;p=thirdparty%2Fbacula.git Fix memory leak when restore is aborted --- diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index f97e61b17..0b401ed44 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -162,6 +162,9 @@ RBSR *new_bsr() void free_bsr(rblist *bsr_list) { RBSR *bsr; + if (!bsr_list) { + return; /* Already done */ + } foreach_rblist(bsr, bsr_list) { delete bsr->fi_list; if (bsr->VolParams) { diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 2c71c176a..64f17ef71 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -413,21 +413,23 @@ int restore_cmd(UAContext *ua, const char *cmd) * line. */ /* ***FIXME*** pass jobids on command line */ - if (jcr->JobIds) { - free_pool_memory(jcr->JobIds); - } + free_and_null_pool_memory(jcr->JobIds); jcr->JobIds = rx.JobIds; rx.JobIds = NULL; + + free_and_null_pool_memory(jcr->component_fname); jcr->component_fname = rx.component_fname; rx.component_fname = NULL; + jcr->component_fd = rx.component_fd; rx.component_fd = NULL; + /* The Client might request the file list */ if (jcr->bsr_list) { free_bsr(jcr->bsr_list); } - /* The Client might request the file list */ jcr->bsr_list = rx.bsr_list; rx.bsr_list = NULL; + parse_ua_args(ua); run_cmd(ua, ua->cmd); free_rx(&rx);