diff src/message.c @ 23946:0b1f5717dc4d v8.2.2515

patch 8.2.2515: memory access error when truncating an empty message Commit: https://github.com/vim/vim/commit/6281815eccc3ded54960f7798833ceb39561b9a0 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 14 15:37:30 2021 +0100 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 https://github.com/vim/vim/issues/7841)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Feb 2021 15:45:03 +0100
parents 0bd44e94dd14
children 44be09b25619
line wrap: on
line diff
--- 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;