Mercurial > vim
changeset 18368:7b4d9e1377ee v8.1.2178
patch 8.1.2178: accessing uninitialized memory in test
Commit: https://github.com/vim/vim/commit/15ee567809a9808693163dd7c357ef0c172ecc9e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 19 14:35:02 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Oct 2019 14:45:04 +0200 |
parents | fe4dd24be6a2 |
children | dbe92b7679db |
files | src/search.c src/version.c |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/search.c +++ b/src/search.c @@ -4877,7 +4877,7 @@ is_one_char(char_u *pattern, int move, p regmatch.startpos[0].col++; nmatched = vim_regexec_multi(®match, 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, p 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; } }