From: Joshua Colp Date: Sat, 14 Nov 2015 13:02:10 +0000 (-0400) Subject: hashtab: Add NULL check when destroying iterator. X-Git-Tag: 11.21.0-rc1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78734aadf46795094955e6783d5e6f1223b7fa65;p=thirdparty%2Fasterisk.git hashtab: Add NULL check when destroying iterator. 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 --- diff --git a/main/hashtab.c b/main/hashtab.c index 4b765979f3..9b334d4a53 100644 --- a/main/hashtab.c +++ b/main/hashtab.c @@ -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);