diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-25 18:52:22 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-25 18:52:22 +0000 |
commit | ba1f572ed75f61b72213e78fc5091bdd5c987ad2 (patch) | |
tree | a5e32a2d725f1769b658b745bb0748c00946af91 | |
parent | 5c25b836e457584c7e925502cc304e8c7b091acd (diff) |
Prevent false positives when freeing a NULL pointer with MALLOC_DEBUG enabled.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@203230 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/astmm.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/main/astmm.c b/main/astmm.c index b0eb51bf5..8dd5edd3f 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) { |