topos: free old outbound buffer inside SREV_NET_DATA_OUT callback
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 12 Aug 2019 09:17:33 +0000 (11:17 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 12 Aug 2019 09:17:33 +0000 (11:17 +0200)
- GH #2027

src/modules/topos/topos_mod.c

index f6b6a3a..942c545 100644 (file)
@@ -390,6 +390,7 @@ int tps_msg_sent(sr_event_param_t *evp)
        str *obuf;
        int dialog;
        int local;
+       str nbuf = STR_NULL;
 
        obuf = (str*)evp->data;
 
@@ -443,7 +444,15 @@ int tps_msg_sent(sr_event_param_t *evp)
                tps_response_sent(&msg);
        }
 
-       obuf->s = tps_msg_update(&msg, (unsigned int*)&obuf->len);
+       nbuf.s = tps_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);