]> granicus.if.org Git - sysstat/commitdiff
tapestat: avoid double free
authorPeter Schiffer <pschiffe@redhat.com>
Wed, 1 Jun 2016 11:38:36 +0000 (13:38 +0200)
committerPeter Schiffer <pschiffe@redhat.com>
Wed, 1 Jun 2016 11:38:36 +0000 (13:38 +0200)
Avoid possibility of double free in tape_check_tapes_and_realloc() function.

tapestat.c

index 7caf4fa55c2b21c0c759814307761eafcf118f8d..92a60937246fdb2394cb86fd32fd2de23bb46906 100644 (file)
@@ -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);