Module: kamailio Branch: master Commit: 79459d3f87731309641794a2b881ee1cacc5e1f2 URL: https://github.com/kamailio/kamailio/commit/79459d3f87731309641794a2b881ee1cacc5e1f2
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2015-08-25T15:53:02+02:00 jsonrpc-c: free pipe cmd for notifications - fixes leak reported by GH#296 --- Modified: modules/jsonrpc-c/jsonrpc_io.c --- Diff: https://github.com/kamailio/kamailio/commit/79459d3f87731309641794a2b881ee1cacc5e1f2.diff Patch: https://github.com/kamailio/kamailio/commit/79459d3f87731309641794a2b881ee1cacc5e1f2.patch --- diff --git a/modules/jsonrpc-c/jsonrpc_io.c b/modules/jsonrpc-c/jsonrpc_io.c index 9acc149..42d16be 100644 --- a/modules/jsonrpc-c/jsonrpc_io.c +++ b/modules/jsonrpc-c/jsonrpc_io.c @@ -165,7 +165,7 @@ void cmd_pipe_cb(int fd, short event, void *arg) if (!payload) { LM_ERR("Failed to build jsonrpc_request_t (method: %s, params: %s)\n", cmd->method, cmd->params); - return; + goto error; } char *json = (char*)json_object_get_string(payload); @@ -203,7 +203,7 @@ void cmd_pipe_cb(int fd, short event, void *arg) if (timerfd == -1) { LM_ERR("Could not create timerfd."); - return; + goto error; } req->timerfd = timerfd; @@ -217,7 +217,7 @@ void cmd_pipe_cb(int fd, short event, void *arg) if (timerfd_settime(timerfd, 0, itime, NULL) == -1) { LM_ERR("Could not set timer."); - return; + goto error; } pkg_free(itime); struct event *timer_ev = pkg_malloc(sizeof(struct event)); @@ -225,7 +225,7 @@ void cmd_pipe_cb(int fd, short event, void *arg) event_set(timer_ev, timerfd, EV_READ, timeout_cb, req); if(event_add(timer_ev, NULL) == -1) { LM_ERR("event_add failed while setting request timer (%s).", strerror(errno)); - return; + goto error; } req->timer_ev = timer_ev; } else if (!sent) { @@ -239,6 +239,10 @@ void cmd_pipe_cb(int fd, short event, void *arg) pkg_free(ns); json_object_put(payload); + if (cmd->notify_only) free_pipe_cmd(cmd); +error: + if (cmd->notify_only) free_pipe_cmd(cmd); + return; } void socket_cb(int fd, short event, void *arg) _______________________________________________ sr-dev mailing list [email protected] http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
