[sr-dev] git:5.2:d815945c: gzcompress: free old outbound buffer inside SREV_NET_DATA_OUT callback

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


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

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

gzcompress: free old outbound buffer inside SREV_NET_DATA_OUT callback

(cherry picked from commit d9a1cbc8f66f9fd0991048e5e1ba1579916a092e)

---

Modified: src/modules/gzcompress/gzcompress_mod.c

---

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

---

diff --git a/src/modules/gzcompress/gzcompress_mod.c b/src/modules/gzcompress/gzcompress_mod.c
index 3e06c1c267..3ff22d723d 100644
--- a/src/modules/gzcompress/gzcompress_mod.c
+++ b/src/modules/gzcompress/gzcompress_mod.c
@@ -338,6 +338,7 @@ int gzc_msg_sent(sr_event_param_t *evp)
 	unsigned long olen;
 	unsigned long nlen;
 	int ret;
+	str nbuf = STR_NULL;
 
 	obuf = (str*)evp->data;
 	memset(&msg, 0, sizeof(sip_msg_t));
@@ -383,7 +384,15 @@ int gzc_msg_sent(sr_event_param_t *evp)
 		goto done;
 	}
 
-	obuf->s = gzc_msg_update(&msg, (unsigned int*)&obuf->len);
+	nbuf.s = gzc_msg_update(&msg, (unsigned int*)&nbuf.len);
+	if(nbuf.s!=NULL) {
+		LM_DBG("new outbound buffer generated\n");
+		pkg_free(obuf->s);
+		obuf->s = nbuf.s;
+		obuf->len = nbuf.len;
+	} else {
+		LM_ERR("failed to generate new outbound buffer\n");
+	}
 
 done:
 	free_sip_msg(&msg);




More information about the sr-dev mailing list