aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorckelsel <ckelsel@hotmail.com>2018-01-15 19:27:10 +0800
committerckelsel <ckelsel@hotmail.com>2018-01-15 19:41:01 +0800
commit63bb7198dfded8a5c37195ebc8503516a1eda0f3 (patch)
treeb1ef735eea420b072ef2d4a945545547f33aff09
parent9ddeb6e187e6ef6045bf037e4225dc46c8efb693 (diff)
downloadrneovim-63bb7198dfded8a5c37195ebc8503516a1eda0f3.tar.gz
rneovim-63bb7198dfded8a5c37195ebc8503516a1eda0f3.tar.bz2
rneovim-63bb7198dfded8a5c37195ebc8503516a1eda0f3.zip
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) https://github.com/vim/vim/commit/66727e16079fbac6db3897b5c3736ec9fba995bb
-rw-r--r--src/nvim/search.c8
-rw-r--r--src/nvim/testdir/test_search.vim7
2 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 1eb1a25a19..0a266382ec 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -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 (;; ) {
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index a333e7f206..03112df46f 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -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