[sr-dev] git:4.0: core: safety check for double free in q_malloc as in f_malloc

Daniel-Constantin Mierla miconda at gmail.com
Wed Dec 11 09:53:33 CET 2013


Module: sip-router
Branch: 4.0
Commit: 060f90439f7a91f42c983f6c6d19a3131f476258
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=060f90439f7a91f42c983f6c6d19a3131f476258

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at 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;




More information about the sr-dev mailing list