From: Mark Michelson Date: Thu, 25 Jun 2009 18:52:22 +0000 (+0000) Subject: Prevent false positives when freeing a NULL pointer with MALLOC_DEBUG enabled. X-Git-Tag: 1.4.26~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=140d84dfc550234541cdac8351e1c92cf982e992;p=thirdparty%2Fasterisk.git Prevent false positives when freeing a NULL pointer with MALLOC_DEBUG enabled. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@203230 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/astmm.c b/main/astmm.c index b0eb51bf58..8dd5edd3fb 100644 --- a/main/astmm.c +++ b/main/astmm.c @@ -157,10 +157,16 @@ static inline size_t __ast_sizeof_region(void *ptr) static void __ast_free_region(void *ptr, const char *file, int lineno, const char *func) { - int hash = HASH(ptr); + int hash; struct ast_region *reg, *prev = NULL; unsigned int *fence; + if (!ptr) { + return; + } + + hash = HASH(ptr); + ast_mutex_lock(®lock); for (reg = regions[hash]; reg; reg = reg->next) { if (reg->data == ptr) {