# HG changeset patch # User Christian Brabandt # Date 1488403804 -3600 # Node ID 654fc5636b37b27891150fd94a4208456e1b96aa # Parent da1cbfa57265cd8cc5efcab60da6611fd77e0174 patch 8.0.0398: illegal memory access with "t" commit https://github.com/vim/vim/commit/66727e16079fbac6db3897b5c3736ec9fba995bb Author: Bram Moolenaar Date: Wed Mar 1 22:17:05 2017 +0100 patch 8.0.0398: illegal memory access with "t" Problem: Illegal memory access with "t". Solution: Use strncmp() instead of memcmp(). (Dominique Pelle, closes https://github.com/vim/vim/issues/1528) diff --git a/src/search.c b/src/search.c --- 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 --- 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 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 398, +/**/ 397, /**/ 396,