diff --git a/main/astmm.c b/main/astmm.c index 04a19037dd..60543ecbc2 100644 --- a/main/astmm.c +++ b/main/astmm.c @@ -156,10 +156,15 @@ 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) {