]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Prevent false positives when freeing a NULL pointer with MALLOC_DEBUG enabled.
authorMark Michelson <mmichelson@digium.com>
Thu, 25 Jun 2009 18:52:22 +0000 (18:52 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 25 Jun 2009 18:52:22 +0000 (18:52 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@203230 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/astmm.c

index b0eb51bf58e6d8301f33ce083351295bab3da77e..8dd5edd3fb64641556384b85f32d85f73d003e24 100644 (file)
@@ -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(&reglock);
        for (reg = regions[hash]; reg; reg = reg->next) {
                if (reg->data == ptr) {