aboutsummaryrefslogtreecommitdiffstats
path: root/main/astmm.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-17 20:25:40 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-09-17 20:25:40 +0000
commit705105e678d3d4542e36f74507426b141efc93bb (patch)
treec9044f8e040e7fbfe881fc5555cd33ff2145d485 /main/astmm.c
parent2503a199c41a193be1d3e3c1939d5cd588e8efe6 (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: http://svn.digium.com/svn/asterisk/trunk@143400 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/astmm.c')
-rw-r--r--main/astmm.c7
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(&reglock);
for (reg = regions[hash]; reg; reg = reg->next) {
if (reg->data == ptr) {