Skip to content

Commit 04bff88

Browse files
committed
patch 7.4.1052
Problem: Illegal memory access with weird syntax command. (Dominique Pelle) Solution: Check for column past end of line.
1 parent af8af8b commit 04bff88

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/syntax.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,8 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos,
30223022
if (r && regmatch.startpos[0].col
30233023
<= best_regmatch.startpos[0].col)
30243024
{
3025+
int line_len;
3026+
30253027
/* Add offset to skip pattern match */
30263028
syn_add_end_off(&pos, &regmatch, spp_skip, SPO_ME_OFF, 1);
30273029

@@ -3031,6 +3033,7 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos,
30313033
break;
30323034

30333035
line = ml_get_buf(syn_buf, startpos->lnum, FALSE);
3036+
line_len = (int)STRLEN(line);
30343037

30353038
/* take care of an empty match or negative offset */
30363039
if (pos.col <= matchcol)
@@ -3040,12 +3043,12 @@ find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos,
30403043
else
30413044
/* Be careful not to jump over the NUL at the end-of-line */
30423045
for (matchcol = regmatch.endpos[0].col;
3043-
line[matchcol] != NUL && matchcol < pos.col;
3046+
matchcol < line_len && matchcol < pos.col;
30443047
++matchcol)
30453048
;
30463049

30473050
/* if the skip pattern includes end-of-line, break here */
3048-
if (line[matchcol] == NUL)
3051+
if (matchcol >= line_len)
30493052
break;
30503053

30513054
continue; /* start with first end pattern again */

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1052,
744746
/**/
745747
1051,
746748
/**/

0 commit comments

Comments
 (0)