diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-07-02 15:15:17 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2021-07-02 22:32:19 +0100 |
commit | 107e21635bb59a01bc92dda05211b03a7d40bde6 (patch) | |
tree | e7a01e985f6db54cb29ece5ca357dcca626b4645 | |
parent | f127fed75d3bae3a1eb0be6feea334bb8d1c3a43 (diff) | |
download | systemd-107e21635bb59a01bc92dda05211b03a7d40bde6.tar.gz |
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.
-rw-r--r-- | src/basic/hashmap.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 9ed69bd3d2..0decbb04e1 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -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; |