Skip to content

Commit

Permalink
Fix btape crash on quit.
Browse files Browse the repository at this point in the history
- Instead of freeing the config before tearing down the whole
  setup only do it when we are really done with the config and
  just before we are about to exit the program.
- don't allocate jcr->comment in butil.c as the setup_jcr function
  already calls new_jcr which also allocated this member and as such
  the memory is leaked and smartalloc complains on exit.

Fixed #91: btape crashes after quit command
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent cd21e97 commit 8b1e79c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 13 additions & 11 deletions src/stored/btape.c
Expand Up @@ -335,23 +335,15 @@ int main(int margc, char *margv[])

static void terminate_btape(int status)
{

Dsm_check(200);
free_jcr(jcr);
jcr = NULL;

if (configfile) {
free(configfile);
}
if (config) {
config->free_resources();
free(config);
config = NULL;
}
if (args) {
free_pool_memory(args);
args = NULL;
}

if (cmd) {
free_pool_memory(cmd);
cmd = NULL;
Expand All @@ -361,15 +353,25 @@ static void terminate_btape(int status)
free_bsr(bsr);
}


free_volume_lists();

if (dev) {
dev->term();
}

if (debug_level > 10)
if (configfile) {
free(configfile);
}

if (config) {
config->free_resources();
free(config);
config = NULL;
}

if (debug_level > 10) {
print_memory_pool_stats();
}

if (this_block) {
free_block(this_block);
Expand Down
2 changes: 0 additions & 2 deletions src/stored/butil.c
Expand Up @@ -99,8 +99,6 @@ JCR *setup_jcr(const char *name, char *dev_name,
pm_strcpy(jcr->fileset_name, "Dummy.fileset.name");
jcr->fileset_md5 = get_pool_memory(PM_FNAME);
pm_strcpy(jcr->fileset_md5, "Dummy.fileset.md5");
jcr->comment = get_pool_memory(PM_MESSAGE);
*jcr->comment = '\0';

new_plugins(jcr); /* instantiate plugins */

Expand Down

0 comments on commit 8b1e79c

Please sign in to comment.