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) {