changeset 7500:ef568437e49a v7.4.1052

commit https://github.com/vim/vim/commit/04bff88df6211f64731bf8f5afa088e94496db16 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 5 20:46:16 2016 +0100 patch 7.4.1052 Problem: Illegal memory access with weird syntax command. (Dominique Pelle) Solution: Check for column past end of line.
author Christian Brabandt <cb@256bit.org>
date Tue, 05 Jan 2016 21:00:05 +0100
parents 0f3b316a0db5
children 2fc964bd0744
files src/syntax.c src/version.c
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3022,6 +3022,8 @@ find_endpos(idx, startpos, m_endpos, hl_
 	    if (r && regmatch.startpos[0].col
 					     <= best_regmatch.startpos[0].col)
 	    {
+		int line_len;
+
 		/* Add offset to skip pattern match */
 		syn_add_end_off(&pos, &regmatch, spp_skip, SPO_ME_OFF, 1);
 
@@ -3031,6 +3033,7 @@ find_endpos(idx, startpos, m_endpos, hl_
 		    break;
 
 		line = ml_get_buf(syn_buf, startpos->lnum, FALSE);
+		line_len = (int)STRLEN(line);
 
 		/* take care of an empty match or negative offset */
 		if (pos.col <= matchcol)
@@ -3040,12 +3043,12 @@ find_endpos(idx, startpos, m_endpos, hl_
 		else
 		    /* Be careful not to jump over the NUL at the end-of-line */
 		    for (matchcol = regmatch.endpos[0].col;
-			    line[matchcol] != NUL && matchcol < pos.col;
+			    matchcol < line_len && matchcol < pos.col;
 								   ++matchcol)
 			;
 
 		/* if the skip pattern includes end-of-line, break here */
-		if (line[matchcol] == NUL)
+		if (matchcol >= line_len)
 		    break;
 
 		continue;	    /* start with first end pattern again */
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1052,
+/**/
     1051,
 /**/
     1050,