[sr-dev] git:master:ee7496f1: siptrace: siptrace: fix memory leak in fake replies tracing

Federico Cabiddu federico.cabiddu at gmail.com
Wed Apr 22 14:05:34 CEST 2020


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

Author: Federico Cabiddu <federico.cabiddu at gmail.com>
Committer: Federico Cabiddu <federico.cabiddu at gmail.com>
Date: 2020-04-22T10:54:29+02:00

siptrace: siptrace: fix memory leak in fake replies tracing

---

Modified: src/modules/siptrace/siptrace.c

---

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

---

diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index 3bd1f5a98c..26e9323ec7 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -1569,6 +1569,7 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)
 	siptrace_data_t sto;
 	siptrace_info_t* info;
 	int faked = 0;
+	int parsed_f = 0;
 	struct sip_msg *msg;
 	struct sip_msg *req;
 	struct ip_addr to_ip;
@@ -1607,6 +1608,11 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)
 	if(msg == NULL || msg == FAKED_REPLY) {
 		msg = t->uas.request;
 		faked = 1;
+		/* check if from header has been already parsed.
+		 * If not we have to parse it in pkg memory and free it at the end.
+		 */
+		if (msg->from && msg->from->parsed == NULL)
+			parsed_f = 1;
 	}
 
 	if(sip_trace_msg_attrs(msg, &sto) < 0) {
@@ -1686,10 +1692,16 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)
 
 	if (info->uriState == STRACE_RAW_URI) {
 		LM_BUG("uriState must be either UNUSED or PARSED here! must be a bug! Message won't be traced!\n");
-		return;
+		goto end;
 	}
 
 	sip_trace_store(&sto, info->uriState == STRACE_PARSED_URI ? &info->u.dest_info : NULL, NULL);
+
+end:
+	if (faked && parsed_f) {
+		free_from(msg->from->parsed);
+    msg->from->parsed = NULL;
+	}
 }
 
 static void trace_tm_neg_ack_in(struct cell *t, int type, struct tmcb_params *ps)




More information about the sr-dev mailing list