]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findmnt: (verify) fix memory leak [asan]
authorKarel Zak <kzak@redhat.com>
Thu, 10 Jun 2021 11:35:05 +0000 (13:35 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 10 Jun 2021 11:35:05 +0000 (13:35 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findmnt-verify.c

index 7de75912f45b6fa2377dbb25a43f6fc64667bbef..2ef7ecff32e8592daa5be4e2696a12d4ad57b905 100644 (file)
@@ -339,6 +339,18 @@ static int read_proc_filesystems(struct verify_context *vfy)
        return rc;
 }
 
+static void free_proc_filesystems(struct verify_context *vfy)
+{
+       size_t n;
+
+       if (!vfy->fs_ary)
+               return;
+
+       for (n = 0; n < vfy->fs_num; n++ )
+               free(vfy->fs_ary[n]);
+       free(vfy->fs_ary);
+}
+
 static int read_kernel_filesystems(struct verify_context *vfy)
 {
        int rc = 0;
@@ -542,5 +554,8 @@ done:
        } else
                fprintf(stdout, _("Success, no errors or warnings detected\n"));
 
+
+       free_proc_filesystems(&vfy);
+
        return rc != 0 ? rc : vfy.nerrors + parse_nerrors;
 }