vim-patch:8.0.0398: illegal memory access with "t"

Problem:    Illegal memory access with "t".
Solution:   Use strncmp() instead of memcmp(). (Dominique Pelle, closes vim/vim#1528)

66727e1607
This commit is contained in:
ckelsel 2018-01-15 19:27:10 +08:00
parent 9ddeb6e187
commit 63bb7198df
2 changed files with 11 additions and 4 deletions

View File

@ -1382,13 +1382,13 @@ int searchc(cmdarg_T *cap, int t_cmd)
col -= (*mb_head_off)(p, p + col - 1) + 1;
}
if (lastc_bytelen == 1) {
if (p[col] == c && stop)
if (p[col] == c && stop) {
break;
} else {
if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0 && stop)
}
} else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) {
break;
}
stop = TRUE;
stop = true;
}
} else {
for (;; ) {

View File

@ -298,3 +298,10 @@ func Test_searchpair()
q!
endfunc
func Test_searchc()
" These commands used to cause memory overflow in searchc().
new
norm ixx
exe "norm 0t\u93cf"
bw!
endfunc