findmnt: (verify) fix memory leak [asan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-06-10 13:35:05 +02:00
parent 3c3f7722ae
commit a71f7f1173
1 changed files with 15 additions and 0 deletions

View 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;
}