From: Sami Kerola Date: Sun, 3 Apr 2016 16:34:53 +0000 (+0100) Subject: libmount: fix memory leak X-Git-Tag: v2.28.1~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bcddfdb2ab83779e27a8c38fec806dccf7aaf02f;p=thirdparty%2Futil-linux.git libmount: fix memory leak Found with scan-build. Signed-off-by: Sami Kerola --- diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 0fcc1d0704..8b80609e99 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -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)