vim-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 vim/vim#5088)
15ee567809
This commit is contained in:
Jan Edmund Lazo
2019-10-19 11:57:34 -04:00
parent 437fe261ab
commit d27fc08257

View File

@@ -4184,7 +4184,7 @@ static int is_one_char(char_u *pattern, bool move, pos_T *cur,
nmatched = vim_regexec_multi(&regmatch, curwin, curbuf,
pos.lnum, regmatch.startpos[0].col,
NULL, NULL);
if (!nmatched) {
if (nmatched != 0) {
break;
}
} while (direction == FORWARD
@@ -4196,7 +4196,10 @@ static int is_one_char(char_u *pattern, bool move, pos_T *cur,
&& 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) {
if (!result
&& nmatched != 0
&& inc(&pos) >= 0
&& pos.col == regmatch.endpos[0].col) {
result = true;
}
}