From: Bram Moolenaar Date: Wed, 1 Mar 2017 21:17:05 +0000 (+0100) Subject: patch 8.0.0398: illegal memory access with "t" X-Git-Tag: v8.0.0398 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66727e16079fbac6db3897b5c3736ec9fba995bb;p=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 #1528) --- diff --git a/src/search.c b/src/search.c index 83c584272..d23dde2c8 100644 --- a/src/search.c +++ b/src/search.c @@ -1693,12 +1693,9 @@ searchc(cmdarg_T *cap, int t_cmd) 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 040a8098a..1a114c44c 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -294,3 +294,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 diff --git a/src/version.c b/src/version.c index 26b5455ab..c1f426cb3 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 398, /**/ 397, /**/