]> err.no Git - util-linux/commitdiff
wipefs: fix memory leaks
authorKarel Zak <kzak@redhat.com>
Wed, 16 Jun 2010 21:41:33 +0000 (23:41 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Jun 2010 21:41:33 +0000 (23:41 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/wipefs.c

index 1db72fd1cf06d5a5b20b0fa7fdfbde78602a3909..c0b29f0ec12a444c6bd35090eac8c37792703e23 100644 (file)
@@ -303,6 +303,23 @@ do_wipe(struct wipe_desc *wp, const char *fname, int noact)
        return 0;
 }
 
+static void
+free_wipe(struct wipe_desc *wp)
+{
+       while (wp) {
+               struct wipe_desc *next = wp->next;
+
+               free(wp->usage);
+               free(wp->type);
+               free(wp->magic);
+               free(wp->label);
+               free(wp->uuid);
+               free(wp);
+
+               wp = next;
+       }
+}
+
 static loff_t
 strtoll_offset(const char *str)
 {
@@ -391,6 +408,8 @@ main(int argc, char **argv)
                        do_wipe(wp, fname, noact);
                else
                        print_all(wp, mode);
+
+               free_wipe(wp);
        }
        return EXIT_SUCCESS;
 }