summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/message.c7
-rw-r--r--src/message_test.c9
-rw-r--r--src/version.c2
3 files changed, 18 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;
diff --git a/src/message_test.c b/src/message_test.c
index 85a29b471..88335de26 100644
--- a/src/message_test.c
+++ b/src/message_test.c
@@ -49,6 +49,15 @@ test_trunc_string(void)
char_u *buf; /*allocated every time to find uninit errors */
char_u *s;
+ // Should not write anything to destination if buflen is 0.
+ trunc_string((char_u *)"", NULL, 1, 0);
+
+ // Truncating an empty string does nothing.
+ buf = alloc(1);
+ trunc_string((char_u *)"", buf, 1, 1);
+ assert(buf[0] == NUL);
+ vim_free(buf);
+
// in place
buf = alloc(40);
STRCPY(buf, "text");
diff --git a/src/version.c b/src/version.c
index 21316e267..f856d83a5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2515,
+/**/
2514,
/**/
2513,