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:
Lennart Poettering
2021-07-02 22:32:19 +01:00
committed by Luca Boccassi
parent f127fed75d
commit 107e21635b
+3
View File
@@ -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;