0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.2178: accessing uninitialized memory in test

Problem:    Accessing uninitialized memory in test.
Solution:   Check if there was a match before using the match position.
            (Dominique Pelle, closes #5088)
This commit is contained in:
Bram Moolenaar 2019-10-19 14:35:02 +02:00
parent afbdb905c3
commit 15ee567809
2 changed files with 6 additions and 3 deletions

View File

@ -4877,7 +4877,7 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction)
regmatch.startpos[0].col++;
nmatched = vim_regexec_multi(&regmatch, curwin, curbuf,
pos.lnum, regmatch.startpos[0].col, NULL, NULL);
if (!nmatched)
if (nmatched != 0)
break;
} while (direction == FORWARD ? regmatch.startpos[0].col < pos.col
: regmatch.startpos[0].col > pos.col);
@ -4887,8 +4887,9 @@ is_one_char(char_u *pattern, int move, pos_T *cur, int direction)
result = (nmatched != 0
&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
&& regmatch.startpos[0].col == regmatch.endpos[0].col);
/* one char width */
if (!result && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col)
// one char width
if (!result && nmatched != 0
&& inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col)
result = TRUE;
}
}

View File

@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2178,
/**/
2177,
/**/