From: Peter Schiffer Date: Wed, 1 Jun 2016 11:38:36 +0000 (+0200) Subject: tapestat: avoid double free X-Git-Tag: v11.3.5~24^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=345b006ac6f27990b2331064fd1c710aa648b06f;p=sysstat tapestat: avoid double free Avoid possibility of double free in tape_check_tapes_and_realloc() function. --- diff --git a/tapestat.c b/tapestat.c index 7caf4fa..92a6093 100644 --- a/tapestat.c +++ b/tapestat.c @@ -210,15 +210,17 @@ void tape_check_tapes_and_realloc(void) if (tape_old_stats_t != NULL) { free(tape_old_stats_t); tape_old_stats_t = NULL; + } else { + free(tape_old_stats); + tape_old_stats = NULL; } if (tape_new_stats_t != NULL) { free(tape_new_stats_t); tape_new_stats_t = NULL; + } else { + free(tape_new_stats); + tape_new_stats = NULL; } - free(tape_old_stats); - tape_old_stats = NULL; - free(tape_new_stats); - tape_new_stats = NULL; perror("realloc"); exit(4);