Skip to content

Commit 66727e1

Browse files
committed
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)
1 parent 5a66dfb commit 66727e1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/search.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,12 +1693,9 @@ searchc(cmdarg_T *cap, int t_cmd)
16931693
if (p[col] == c && stop)
16941694
break;
16951695
}
1696-
else
1697-
{
1698-
if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0
1696+
else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0
16991697
&& stop)
1700-
break;
1701-
}
1698+
break;
17021699
stop = TRUE;
17031700
}
17041701
}

src/testdir/test_search.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,10 @@ func Test_searchpair()
294294
q!
295295
endfunc
296296

297+
func Test_searchc()
298+
" These commands used to cause memory overflow in searchc().
299+
new
300+
norm ixx
301+
exe "norm 0t\u93cf"
302+
bw!
303+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
398,
767769
/**/
768770
397,
769771
/**/

0 commit comments

Comments
 (0)