diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-01-22 16:55:10 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-01-22 16:55:10 -0800 |
commit | 20fef8a7eb2da8a205fb9d58ae61c5dc79e60651 (patch) | |
tree | 1303885467c09a76225d95a2b7fec0179c24c9ae | |
parent | 61c963bba458a186798324178534355221308df4 (diff) | |
parent | 1a090983f53453069487426fcd6dff9c817bb70f (diff) | |
download | rneovim-20fef8a7eb2da8a205fb9d58ae61c5dc79e60651.tar.gz rneovim-20fef8a7eb2da8a205fb9d58ae61c5dc79e60651.tar.bz2 rneovim-20fef8a7eb2da8a205fb9d58ae61c5dc79e60651.zip |
Merge pull request #1847 from JackDanger/safely-freeing-channels
Fix CID #102150
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index c8f8252e6d..920274f850 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -442,17 +442,18 @@ static void handle_request(Channel *channel, msgpack_object *request) if (error.set) { // Validation failed, send response with error - channel_write(channel, - serialize_response(channel->id, - request_id, - &error, - NIL, - &out_buffer)); - char buf[256]; - snprintf(buf, sizeof(buf), - "Channel %" PRIu64 " sent an invalid message, closing.", - channel->id); - call_set_error(channel, buf); + if (channel_write(channel, + serialize_response(channel->id, + request_id, + &error, + NIL, + &out_buffer))) { + char buf[256]; + snprintf(buf, sizeof(buf), + "Channel %" PRIu64 " sent an invalid message, closing.", + channel->id); + call_set_error(channel, buf); + } return; } @@ -619,8 +620,7 @@ static void unsubscribe(Channel *channel, char *event) free(event_string); } -/// Close the channel streams/job. The channel resources will be freed by -/// free_channel later. +/// Close the channel streams/job and free the channel resources. static void close_channel(Channel *channel) { if (channel->closed) { |