aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-30 21:37:51 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-31 10:05:26 +0800
commite2247c0baa78570f7cb81695c28394ce0be73825 (patch)
tree7b7253210f76729244c4832604d554266cee630b
parent47630743fc67c56f724cd99660d86d8c4ea7782f (diff)
downloadrneovim-e2247c0baa78570f7cb81695c28394ce0be73825.tar.gz
rneovim-e2247c0baa78570f7cb81695c28394ce0be73825.tar.bz2
rneovim-e2247c0baa78570f7cb81695c28394ce0be73825.zip
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
-rw-r--r--src/nvim/message.c7
1 files changed, 7 insertions, 0 deletions
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;
}