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>
This commit is contained in:
Karel Zak 2015-07-30 09:28:19 +02:00
parent d8461c4e4d
commit 6b9784b442
1 changed files with 2 additions and 2 deletions

View 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);