[sr-dev] git:5.2:0df6f49f: dialog: free old outbound buffer inside SREV_NET_DATA_OUT callback

Daniel-Constantin Mierla miconda at gmail.com
Tue Aug 20 12:06:08 CEST 2019


Module: kamailio
Branch: 5.2
Commit: 0df6f49fe7a13ce6c01542a16fdd8932043f5ec9
URL: https://github.com/kamailio/kamailio/commit/0df6f49fe7a13ce6c01542a16fdd8932043f5ec9

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-08-15T12:44:31+02:00

dialog: free old outbound buffer inside SREV_NET_DATA_OUT callback

(cherry picked from commit ad8d9628da27a3ab68b005ef52842784af6bda3a)

---

Modified: src/modules/dialog/dlg_cseq.c

---

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

---

diff --git a/src/modules/dialog/dlg_cseq.c b/src/modules/dialog/dlg_cseq.c
index b97e8f7123..29fcaa7494 100644
--- a/src/modules/dialog/dlg_cseq.c
+++ b/src/modules/dialog/dlg_cseq.c
@@ -364,6 +364,7 @@ int dlg_cseq_msg_sent(sr_event_param_t *evp)
 	struct via_body *via;
 	hdr_field_t *hfk = NULL;
 	sr_cfgenv_t *cenv = NULL;
+	str nbuf = STR_NULL;
 
 	obuf = (str*)evp->data;
 	memset(&msg, 0, sizeof(sip_msg_t));
@@ -520,11 +521,13 @@ int dlg_cseq_msg_sent(sr_event_param_t *evp)
 		}
 	}
 	/* replace old msg content */
-	obuf->s = pkg_malloc((tbuf_len+1)*sizeof(char));
-	if(obuf->s==NULL) {
+	nbuf.s = pkg_malloc((tbuf_len+1)*sizeof(char));
+	if(nbuf.s==NULL) {
 		LM_ERR("not enough memory for new message\n");
 		goto done;
 	}
+	pkg_free(obuf->s);
+	obuf->s = nbuf.s;
 	memcpy(obuf->s, tbuf, tbuf_len);
 	obuf->s[tbuf_len] = 0;
 	obuf->len = tbuf_len;




More information about the sr-dev mailing list