forked from aniani/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 #7841)
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user