mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-12 08:58:20 +03:00
hashmap: make sure hashmap_get_strv()+set_get_strv() work with a NULL object
Before we invoke n_entries() we need to check for non-NULL here, like in all other calls to the helper function. Otherwise we'll crash when invoked with a NULL object, which we usually consider equivalent to an empty one though.
This commit is contained in:
parent
f127fed75d
commit
107e21635b
@ -1761,6 +1761,9 @@ char** _hashmap_get_strv(HashmapBase *h) {
|
||||
Iterator i;
|
||||
unsigned idx, n;
|
||||
|
||||
if (!h)
|
||||
return new0(char*, 1);
|
||||
|
||||
sv = new(char*, n_entries(h)+1);
|
||||
if (!sv)
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user