summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorKarel Zak2015-07-30 09:28:19 +0200
committerKarel Zak2015-07-30 09:28:19 +0200
commit6b9784b442aea0b1c454d80bfabb17d0d5eee111 (patch)
treeefb4602fff70ddbada78668b24b870a3446ba343 /libmount/src/utils.c
parentlsipc: cleanup {user,group}name usage (diff)
downloadkernel-qcow2-util-linux-6b9784b442aea0b1c454d80bfabb17d0d5eee111.tar.gz
kernel-qcow2-util-linux-6b9784b442aea0b1c454d80bfabb17d0d5eee111.tar.xz
kernel-qcow2-util-linux-6b9784b442aea0b1c454d80bfabb17d0d5eee111.zip
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 <kzak@redhat.com>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 4814008d6..2bfca28d4 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);