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:
parent
d8461c4e4d
commit
6b9784b442
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue