]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix some errors reported by valgrind. May fix the problem with bsmtp command.
authorEric Bollengier <eric@baculasystems.com>
Tue, 8 Jul 2014 12:22:37 +0000 (14:22 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 26 Jul 2014 08:43:00 +0000 (10:43 +0200)
 Conditional jump or move depends on uninitialised value(s)
    at 0x5045B75: makedir(JCR*, char*, unsigned int, int*) [clone .constprop.3] (mkpath.c:146)

 Syscall param unlink(pathname) points to unaddressable byte(s)
    at 0x74BAF67: unlink (in /usr/lib/libc-2.19.so)
    by 0x430BB9: restore_cleanup(JCR*, int) (restore.c:591)

bacula/src/dird/restore.c
bacula/src/dird/ua_restore.c

index 99bffc6706e866a4d63bdd46e6c909a57b2c62e8..b61c7297144fd3374020cde3d7ffddd5ec8d99ff 100644 (file)
@@ -569,6 +569,15 @@ void restore_cleanup(JCR *jcr, int TermCode)
    Dmsg0(20, "In restore_cleanup\n");
    update_job_end(jcr, TermCode);
 
+   if (jcr->component_fd) {
+      fclose(jcr->component_fd);
+      jcr->component_fd = NULL;
+   }
+   if (jcr->component_fname && *jcr->component_fname) {
+      unlink(jcr->component_fname);
+   }
+   free_and_null_pool_memory(jcr->component_fname);
+
    if (jcr->unlink_bsr && jcr->RestoreBootstrap) {
       unlink(jcr->RestoreBootstrap);
       jcr->unlink_bsr = false;
index ebe8d008f28fc1be32ba0af8be2a85010113547c..1dc1a4046083c947aabd6f83710b9039e5eba6b6 100644 (file)
@@ -75,11 +75,23 @@ int restore_cmd(UAContext *ua, const char *cmd)
 
    memset(&rx, 0, sizeof(rx));
    rx.path = get_pool_memory(PM_FNAME);
+   rx.path[0] = 0;
+
    rx.fname = get_pool_memory(PM_FNAME);
+   rx.fname[0] = 0;
+
    rx.JobIds = get_pool_memory(PM_FNAME);
    rx.JobIds[0] = 0;
+
+   rx.component_fname = get_pool_memory(PM_FNAME);
+   rx.component_fname[0] = 0;
+
    rx.BaseJobIds = get_pool_memory(PM_FNAME);
+   rx.BaseJobIds[0] = 0;
+
    rx.query = get_pool_memory(PM_FNAME);
+   rx.query[0] = 0;
+
    rx.bsr = new_bsr();
    rx.hardlinks_in_mem = true;