From: Karel Zak Date: Thu, 30 Jul 2015 07:28:19 +0000 (+0200) Subject: libmount: make mnt_get_filesystems() more robust [clang analyze] X-Git-Tag: v2.27-rc1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b9784b442aea0b1c454d80bfabb17d0d5eee111;p=thirdparty%2Futil-linux.git libmount: make mnt_get_filesystems() more robust [clang analyze] The mnt_free_filesystems() relies on NULL as the last item in the filesystems array. It's necessary to keep NULL there after failed strdup() too, because we call mnt_free_filesystems() to deallocate after error. Signed-off-by: Karel Zak --- diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 4814008d65..2bfca28d41 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -550,10 +550,10 @@ static int add_filesystem(char ***filesystems, char *name) *filesystems = x; } name = strdup(name); - if (!name) - goto err; (*filesystems)[n] = name; (*filesystems)[n + 1] = NULL; + if (!name) + goto err; return 0; err: mnt_free_filesystems(*filesystems);