summaryrefslogtreecommitdiff
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-02-14 15:37:30 +0100
committerBram Moolenaar <Bram@vim.org>2021-02-14 15:37:30 +0100
commit6281815eccc3ded54960f7798833ceb39561b9a0 (patch)
tree72c092d24c42b3e01f2dc184ba05c71e61bddf3a /src/message.c
parent2379f87eb48a4ee6a1d0fc7df964e12a3efe4fd5 (diff)
downloadvim-git-6281815eccc3ded54960f7798833ceb39561b9a0.tar.gz
patch 8.2.2515: memory access error when truncating an empty messagev8.2.2515
Problem: Memory access error when truncating an empty message. Solution: Check for an empty string. (Dominique Pellé, closes #7841)
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/message.c b/src/message.c
index 8adc22411..012811f9c 100644
--- a/src/message.c
+++ b/src/message.c
@@ -248,6 +248,13 @@ trunc_string(
int i;
int n;
+ if (*s == NUL)
+ {
+ if (buflen > 0)
+ *buf = NUL;
+ return;
+ }
+
if (room_in < 3)
room = 0;
half = room / 2;