diff options
author | Mark Michelson <mmichelson@digium.com> | 2008-09-17 20:25:40 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2008-09-17 20:25:40 +0000 |
commit | 48ffe6e77276831f2e8a77e7caac67467035a7f7 (patch) | |
tree | c9044f8e040e7fbfe881fc5555cd33ff2145d485 /main/astmm.c | |
parent | 224980b07b236cdc2e67ca3bd69940a9b92a8275 (diff) |
If attempting to free a NULL pointer when MALLOC_DEBUG
is set, don't bother searching for a region to free, just
immediately exit.
This has the dual benefit of suppressing a warning message
about freeing memory at (nil) and of optimizing the free()
replacement by not having to do any futile searching for
the proper region to free.
(closes issue #13498)
Reported by: pj
Patches:
13498.patch uploaded by putnopvut (license 60)
Tested by: pj
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@143400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astmm.c')
-rw-r--r-- | main/astmm.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/main/astmm.c b/main/astmm.c index 04a19037d..60543ecbc 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) { |