Module: kamailio
Branch: master
Commit: bcc3857e21634485878eb82d89ca6f4e6b854934
URL:
https://github.com/kamailio/kamailio/commit/bcc3857e21634485878eb82d89ca6f4…
Author: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Committer: GitHub <noreply(a)github.com>
Date: 2016-10-24T17:49:37-04:00
Merge pull request #829 from kamailio/janssonrpc-fix-memory-leak
janssonrpc-c: fix memory leak when using janssonrpc_notification
---
Modified: modules/janssonrpc-c/janssonrpc_io.c
---
Diff:
https://github.com/kamailio/kamailio/commit/bcc3857e21634485878eb82d89ca6f4…
Patch:
https://github.com/kamailio/kamailio/commit/bcc3857e21634485878eb82d89ca6f4…
---
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;
+ }
}
}