patch 8.0.0398: illegal memory access with "t"
Problem: Illegal memory access with "t".
Solution: Use strncmp() instead of memcmp(). (Dominique Pelle, closes #1528)
diff --git a/src/search.c b/src/search.c
index 83c5842..d23dde2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1693,12 +1693,9 @@
if (p[col] == c && stop)
break;
}
- else
- {
- if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0
+ else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0
&& stop)
- break;
- }
+ break;
stop = TRUE;
}
}
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 040a809..1a114c4 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -294,3 +294,10 @@
q!
endfunc
+func Test_searchc()
+ " These commands used to cause memory overflow in searchc().
+ new
+ norm ixx
+ exe "norm 0t\u93cf"
+ bw!
+endfunc
diff --git a/src/version.c b/src/version.c
index 26b5455..c1f426c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 398,
+/**/
397,
/**/
396,