Pārlūkot izejas kodu

mem: safety check for f_malloc to avoind inserting two times free fragments

Daniel-Constantin Mierla 13 gadi atpakaļ
vecāks
revīzija
fbf65a9405
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5 0
      mem/f_malloc.c

+ 5 - 0
mem/f_malloc.c

@@ -524,6 +524,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;