janssonrpc-c: fix double free introduced by
authorEmmanuel Schmidbauer <emmanuel@getweave.com>
Wed, 2 Nov 2016 17:18:15 +0000 (13:18 -0400)
committerEmmanuel Schmidbauer <emmanuel@getweave.com>
Wed, 2 Nov 2016 17:18:15 +0000 (13:18 -0400)
cf8d6066afc102d5904dddec0275079885f0ead1

modules/janssonrpc-c/janssonrpc_io.c

index a25e40d..7cdb229 100644 (file)
@@ -430,6 +430,7 @@ int jsonrpc_send(str conn, jsonrpc_request_t* req, bool notify_only)
 
        if (sent) {
                if (notify_only == true) { // free the request if using janssonrpc_notification function
+                       free_req_cmd(req->cmd);
                        free_request(req);
                } else {
                        const struct timeval tv = ms_to_tv(req->timeout);
@@ -534,8 +535,6 @@ void cmd_pipe_cb(int fd, short event, void *arg)
                WARN("%s could not be sent to connection group: %.*s\n",
                                type, STR(req_cmd->conn));
                fail_request(JRPC_ERR_SEND, req, "Failed to send request");
-       } else if (req_cmd->notify_only == true) { // free notification requests if they are sent
-               free_req_cmd(req_cmd);
        }
 
 end: