[sr-dev] git:3.1: mem: safety check for f_malloc to avoind inserting two times free fragments

Anca Vamanu anca.vamanu at 1and1.ro
Mon Aug 20 13:51:58 CEST 2012


Module: sip-router
Branch: 3.1
Commit: 1db591ed633a101a150f9b66bf6556329590dc64
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1db591ed633a101a150f9b66bf6556329590dc64

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Anca Vamanu <anca.vamanu at 1and1.ro>
Date:   Mon Apr  2 09:50:17 2012 +0200

mem: safety check for f_malloc to avoind inserting two times free fragments
(cherry picked from commit fbf65a9405e9d1618a94a1e4c23390b8575445b8)

---

 mem/f_malloc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index 6fa88c3..54cbb34 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -440,6 +440,11 @@ void fm_free(struct fm_block* qm, void* p)
 	MDBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n",
 			f->file, f->func, f->line);
 #endif
+	if(unlikely(f->u.nxt_free!=NULL)) {
+		LM_INFO("freeing a free fragment (%p/%p) - ignore\n",
+				f, p);
+		return;
+	}
 	size=f->size;
 #if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
 	qm->used-=size;




More information about the sr-dev mailing list