]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
hashtab: Add NULL check when destroying iterator. 32/1632/1
authorJoshua Colp <jcolp@digium.com>
Sat, 14 Nov 2015 13:02:10 +0000 (09:02 -0400)
committerJoshua Colp <jcolp@digium.com>
Sat, 14 Nov 2015 13:02:10 +0000 (09:02 -0400)
The hashtab API is pretty NULL tolerant which has resulted
in remaining callers not doing much checks themselves.
Unfortunately the function to destroy an iterator does not
do a NULL check and will result in a crash if passed NULL.
This change fixes that.

ASTERISK-25552 #close

Change-Id: Ic1bf8eec3639e5a440f1c941d3ae3893ac6ed619

main/hashtab.c

index 4b765979f32768fdbc4c9baaf8a7ea272cc8f77f..9b334d4a53e88c7d850ff61860a15be83a5b6a09 100644 (file)
@@ -745,6 +745,8 @@ struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *t
 
 void ast_hashtab_end_traversal(struct ast_hashtab_iter *it)
 {
+       if (!it)
+               return;
        if (it->tab->do_locking)
                ast_rwlock_unlock(&it->tab->lock);
        free(it);