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

Author: Emmanuel Schmidbauer <emman...@getweave.com>
Committer: Emmanuel Schmidbauer <emman...@getweave.com>
Date: 2016-10-24T15:53:29-04:00

janssonrpc-c: fix memory leak when using janssonrpc_notification

---

Modified: modules/janssonrpc-c/janssonrpc_io.c

---

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

---

diff --git a/modules/janssonrpc-c/janssonrpc_io.c 
b/modules/janssonrpc-c/janssonrpc_io.c
index ed0be6c..036032e 100644
--- a/modules/janssonrpc-c/janssonrpc_io.c
+++ b/modules/janssonrpc-c/janssonrpc_io.c
@@ -428,15 +428,18 @@ int jsonrpc_send(str conn, jsonrpc_request_t* req, bool 
notify_only)
        if(ns) pkg_free(ns);
        if(json) free(json);
 
-       if (sent && notify_only == false) {
-
-               const struct timeval tv = ms_to_tv(req->timeout);
+       if (sent) {
+               if (notify_only == true) { // free the request if using 
janssonrpc_notification function
+                       free_request(req);
+               } else {
+                       const struct timeval tv = ms_to_tv(req->timeout);
 
-               req->timeout_ev = evtimer_new(global_ev_base, timeout_cb, 
(void*)req);
-               if(event_add(req->timeout_ev, &tv)<0) {
-                       ERR("event_add failed while setting request timer 
(%s).",
-                                       strerror(errno));
-                       return -1;
+                       req->timeout_ev = evtimer_new(global_ev_base, 
timeout_cb, (void*)req);
+                       if(event_add(req->timeout_ev, &tv)<0) {
+                               ERR("event_add failed while setting request 
timer (%s).",
+                                               strerror(errno));
+                               return -1;
+                       }
                }
        }
 


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to