aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornwounkn <nwounkn@gmail.com>2023-08-16 04:33:39 +0500
committerLewis Russell <me@lewisr.dev>2024-01-21 23:42:58 +0000
commit4d4092ac9e98f04ae949c605aa6e2b55ca605a1f (patch)
tree8c3317ffdb5f873f2264b2154d1f511c7f0a19d4 /src
parentf8310beeed049ae5aadd3baa60ae49298bc04538 (diff)
downloadrneovim-4d4092ac9e98f04ae949c605aa6e2b55ca605a1f.tar.gz
rneovim-4d4092ac9e98f04ae949c605aa6e2b55ca605a1f.tar.bz2
rneovim-4d4092ac9e98f04ae949c605aa6e2b55ca605a1f.zip
fix(rpc): assertion failure due to invalid msgpack input
Problem: rbuffer_consumed assertion fails if Unpacker fails to parse msgpack, because it doesn't consume bytes on errors Solution: Call rbuffer_consumed_compact only if Unpacker isn't closed
Diffstat (limited to 'src')
-rw-r--r--src/nvim/msgpack_rpc/channel.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 286bb8098a..0178ef622b 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -304,8 +304,11 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data,
p->read_ptr = rbuffer_read_ptr(rbuf, &size);
p->read_size = size;
parse_msgpack(channel);
- size_t consumed = size - p->read_size;
- rbuffer_consumed_compact(rbuf, consumed);
+
+ if (!unpacker_closed(p)) {
+ size_t consumed = size - p->read_size;
+ rbuffer_consumed_compact(rbuf, consumed);
+ }
end:
channel_decref(channel);