Browse code

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

Daniel-Constantin Mierla authored on 02/04/2012 07:50:17 • Anca Vamanu committed on 20/08/2012 11:49:02
Showing 1 changed files
... ...
@@ -440,6 +440,11 @@ void fm_free(struct fm_block* qm, void* p)
440 440
 	MDBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n",
441 441
 			f->file, f->func, f->line);
442 442
 #endif
443
+	if(unlikely(f->u.nxt_free!=NULL)) {
444
+		LM_INFO("freeing a free fragment (%p/%p) - ignore\n",
445
+				f, p);
446
+		return;
447
+	}
443 448
 	size=f->size;
444 449
 #if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
445 450
 	qm->used-=size;