]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: fix memmory leak [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 12 Dec 2012 11:40:48 +0000 (12:40 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Dec 2012 11:40:48 +0000 (12:40 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/swapon.c

index 47ff508168c7a5e58942aab2e62cf8010b6b968f..176be426e14e509b00ec32f3c02d024a30570786 100644 (file)
@@ -211,11 +211,11 @@ static int display_summary(void)
 static int show_table(int tt_flags, int bytes)
 {
        struct libmnt_table *st = get_swaps();
-       struct libmnt_iter *itr;
+       struct libmnt_iter *itr = NULL;
        struct libmnt_fs *fs;
 
        int i, rc = 0;
-       struct tt *tt;
+       struct tt *tt = NULL;
 
        if (!st)
                return -1;
@@ -227,7 +227,7 @@ static int show_table(int tt_flags, int bytes)
        tt = tt_new_table(tt_flags);
        if (!tt) {
                warn(_("failed to initialize output table"));
-               return -1;
+               goto done;
        }
 
        for (i = 0; i < ncolumns; i++) {
@@ -243,9 +243,9 @@ static int show_table(int tt_flags, int bytes)
        while (mnt_table_next_fs(st, itr, &fs) == 0)
                add_tt_line(tt, fs, bytes);
 
-       mnt_free_iter(itr);
        tt_print_table(tt);
  done:
+       mnt_free_iter(itr);
        tt_free_table(tt);
        return rc;
 }