]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix memory leak
authorSami Kerola <kerolasa@iki.fi>
Sun, 3 Apr 2016 16:34:53 +0000 (17:34 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jun 2016 09:20:43 +0000 (11:20 +0200)
Found with scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libmount/src/utils.c

index 0fcc1d0704c4617d9d215c047625063098d10896..8b80609e99fd5af3b47801520fae319a3766f022 100644 (file)
@@ -1107,7 +1107,7 @@ char *mnt_get_kernel_cmdline_option(const char *name)
 int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path)
 {
        char buf[PATH_MAX];
-       char *dev = NULL, *spec;
+       char *dev = NULL, *spec = NULL;
        unsigned int x, y;
        int allocated = 0;
 
@@ -1169,8 +1169,8 @@ int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path)
                if (dev && !cache)
                        allocated = 1;
        }
-       free(spec);
 done:
+       free(spec);
        if (dev) {
                *path = allocated ? dev : strdup(dev);
                if (!path)