vim-patch:7.4.2068

Problem:    Not all arguments of trunc_string() are tested.  Memory access
            error when running the message tests.
Solution:   Add another test case. (Yegappan Lakshmanan)  Make it easy to run
            unittests with valgrind.  Fix the access error.

b9644433d2
This commit is contained in:
James McCoy
2017-03-06 12:14:39 -05:00
parent 7217360e34
commit 4e3a2784ec
3 changed files with 22 additions and 12 deletions

View File

@@ -274,9 +274,9 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
for (;;) {
do {
half = half - (*mb_head_off)(s, s + half - 1) - 1;
} while (utf_iscomposing(utf_ptr2char(s + half)) && half > 0);
} while (half > 0 && utf_iscomposing(utf_ptr2char(s + half)));
n = ptr2cells(s + half);
if (len + n > room) {
if (len + n > room || half == 0) {
break;
}
len += n;