]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix resource leak [coverity scan]
authorKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 22:27:23 +0000 (23:27 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 30 Jan 2012 22:27:23 +0000 (23:27 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/utils.c

index 0bd7c361b551a94c3c03cda45a5342e68bdc6521..823289e5f926f8958de2f934aa22fb560f469b3b 100644 (file)
@@ -427,6 +427,7 @@ err:
 
 static int get_filesystems(const char *filename, char ***filesystems, const char *pattern)
 {
+       int rc = 0;
        FILE *f;
        char line[128];
 
@@ -436,7 +437,6 @@ static int get_filesystems(const char *filename, char ***filesystems, const char
 
        while (fgets(line, sizeof(line), f)) {
                char name[sizeof(line)];
-               int rc;
 
                if (*line == '#' || strncmp(line, "nodev", 5) == 0)
                        continue;
@@ -446,9 +446,11 @@ static int get_filesystems(const char *filename, char ***filesystems, const char
                        continue;
                rc = add_filesystem(filesystems, name);
                if (rc)
-                       return rc;
+                       break;
        }
-       return 0;
+
+       fclose(f);
+       return rc;
 }
 
 int mnt_get_filesystems(char ***filesystems, const char *pattern)