commit e2247c0baa78570f7cb81695c28394ce0be73825
parent 47630743fc67c56f724cd99660d86d8c4ea7782f
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 30 Mar 2022 21:37:51 +0800
vim-patch:8.2.2515: memory access error when truncating an empty message
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
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git 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;
}