From e2247c0baa78570f7cb81695c28394ce0be73825 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 30 Mar 2022 21:37:51 +0800 Subject: vim-patch:8.2.2515: memory access error when truncating an empty message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Memory access error when truncating an empty message. Solution: Check for an empty string. (Dominique Pellé, closes vim/vim#7841) https://github.com/vim/vim/commit/6281815eccc3ded54960f7798833ceb39561b9a0 --- src/nvim/message.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 7b90f882ab..3ad38f7b77 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -382,6 +382,13 @@ void trunc_string(char_u *s, char_u *buf, int room_in, int buflen) int i; int n; + if (*s == NUL) { + if (buflen > 0) { + *buf = NUL; + } + return; + } + if (room_in < 3) { room = 0; } -- cgit