]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: make mnt_get_filesystems() more robust [clang analyze]
authorKarel Zak <kzak@redhat.com>
Thu, 30 Jul 2015 07:28:19 +0000 (09:28 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 30 Jul 2015 07:28:19 +0000 (09:28 +0200)
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>
libmount/src/utils.c

index 4814008d65670fd723706ca6a2e7a33620c4be8c..2bfca28d41d0cf0c26e2ad62c6f991c11a6499d9 100644 (file)
@@ -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);