From 6b9784b442aea0b1c454d80bfabb17d0d5eee111 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 30 Jul 2015 09:28:19 +0200 Subject: [PATCH] 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 --- libmount/src/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.47.3