Преглед изворни кода

janssonrpc-c: fix double free introduced by
cf8d6066afc102d5904dddec0275079885f0ead1

Emmanuel Schmidbauer пре 9 година
родитељ
комит
c73a7eab21
1 измењених фајлова са 1 додато и 2 уклоњено
  1. 1 2
      modules/janssonrpc-c/janssonrpc_io.c

+ 1 - 2
modules/janssonrpc-c/janssonrpc_io.c

@@ -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: