From: Holger Schemel Date: Tue, 27 Feb 2024 19:24:45 +0000 (+0100) Subject: added checking pointers for hash table iterator X-Git-Tag: 4.4.0.0-test-1~277 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=6e0e50d52f6c2cd5f1686de23375f46847605ee7;p=rocksndiamonds.git added checking pointers for hash table iterator --- diff --git a/src/libgame/hash.c b/src/libgame/hash.c index 4dd904c9..b3595ad4 100644 --- a/src/libgame/hash.c +++ b/src/libgame/hash.c @@ -423,18 +423,24 @@ hashtable_iterator(struct hashtable *h) /* key - return the key of the (key, value) pair at the current position */ void * -hashtable_iterator_key(struct hashtable_itr *i) +hashtable_iterator_key(struct hashtable_itr *itr) { - return i->e->k; + if (itr == NULL || itr->e == NULL) + return NULL; + + return itr->e->k; } /*****************************************************************************/ /* value - return the value of the (key, value) pair at the current position */ void * -hashtable_iterator_value(struct hashtable_itr *i) +hashtable_iterator_value(struct hashtable_itr *itr) { - return i->e->v; + if (itr == NULL || itr->e == NULL) + return NULL; + + return itr->e->v; } /*****************************************************************************/