Module: sip-router
Branch: 4.1
Commit: eaeb74f5b6af5be13f88de93729998f13e9a06b7
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=eaeb74f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Dec 11 09:49:52 2013 +0100
core: safety check for double free in q_malloc as in f_malloc
(cherry picked from commit 943a5941f5ab479803fb30e19e9fa607f0f0fe14)
---
mem/q_malloc.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 50acab9..8c36d03 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -473,6 +473,12 @@ void qm_free(struct qm_block* qm, void* p)
MDBG("qm_free: freeing frag. %p alloc'ed from %s: %s(%ld)\n",
f, f->file, f->func, f->line);
#endif
+ if (unlikely(f->u.is_free)){
+ LM_INFO("freeing a free fragment (%p/%p) - ignore\n",
+ f, p);
+ return;
+ }
+
size=f->size;
qm->used-=size;
qm->real_used-=size;