From 79b915e8df2eaa060e157ed51b8c70fed177d34d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 12 Feb 2017 20:42:49 +0000 Subject: [PATCH] findmnt: fix couple memory leaks [cppcheck] In both cases FILE *f was leaked. Signed-off-by: Sami Kerola --- misc-utils/findmnt-verify.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/misc-utils/findmnt-verify.c b/misc-utils/findmnt-verify.c index b2a88c5f6b..e3fb391d4e 100644 --- a/misc-utils/findmnt-verify.c +++ b/misc-utils/findmnt-verify.c @@ -328,14 +328,15 @@ static int read_proc_filesystems(struct verify_context *vfy) rc = add_filesystem(vfy, cp); if (rc) - return rc; + break; } fclose(f); - return 0; + return rc; } static int read_kernel_filesystems(struct verify_context *vfy) { + int rc = 0; #ifdef __linux__ struct utsname uts; FILE *f; @@ -351,7 +352,6 @@ static int read_kernel_filesystems(struct verify_context *vfy) while (!feof(f)) { char *p, *name; - int rc; if (!fgets(buf, sizeof(buf), f)) break; @@ -377,11 +377,11 @@ static int read_kernel_filesystems(struct verify_context *vfy) rc = add_filesystem(vfy, name); if (rc) - return rc; + break; } fclose(f); #endif /* __linux__ */ - return 0; + return rc; } static int verify_fstype(struct verify_context *vfy) -- 2.47.2