[sr-dev] git:master:43451895: mem: f_malloc - better log message on ignoring double free

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 24 14:28:05 CEST 2018


Module: kamailio
Branch: master
Commit: 434518953c507b41b80adaf1a39b7b8f1e9a3048
URL: https://github.com/kamailio/kamailio/commit/434518953c507b41b80adaf1a39b7b8f1e9a3048

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-09-24T14:27:23+02:00

mem: f_malloc - better log message on ignoring double free

---

Modified: src/core/mem/f_malloc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/434518953c507b41b80adaf1a39b7b8f1e9a3048.diff
Patch: https://github.com/kamailio/kamailio/commit/434518953c507b41b80adaf1a39b7b8f1e9a3048.patch

---

diff --git a/src/core/mem/f_malloc.c b/src/core/mem/f_malloc.c
index 9deaa5b512..a157f03172 100644
--- a/src/core/mem/f_malloc.c
+++ b/src/core/mem/f_malloc.c
@@ -623,12 +623,17 @@ void fm_free(void* qmp, void* p)
 	}
 #ifdef DBG_F_MALLOC
 	if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){
-		LM_CRIT("BUG: bad pointer %p (out of memory block (%p)!),"
+		if(likely(cfg_get(core, core_cfg, mem_safety)==0)) {
+			LM_CRIT("BUG: bad pointer %p (out of memory block (%p)!),"
 				" called from %s: %s(%d) - aborting\n", p, qm,
 				file, func, line);
-		if(likely(cfg_get(core, core_cfg, mem_safety)==0))
 			abort();
-		else return;
+		} else {
+			LM_CRIT("BUG: bad pointer %p (out of memory block (%p)!),"
+				" called from %s: %s(%d) - ignoring\n", p, qm,
+				file, func, line);
+			return;
+		}
 	}
 #endif
 	f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag));




More information about the sr-dev mailing list