]> granicus.if.org Git - vim/commitdiff
patch 8.1.2178: accessing uninitialized memory in test v8.1.2178
authorBram Moolenaar <Bram@vim.org>
Sat, 19 Oct 2019 12:35:02 +0000 (14:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 19 Oct 2019 12:35:02 +0000 (14:35 +0200)
Problem:    Accessing uninitialized memory in test.
Solution:   Check if there was a match before using the match position.
            (Dominique Pelle, closes #5088)

src/search.c
src/version.c

index 91f53c606d5228f45ca218972cfd0bcc61518dba..ab0edc48b980c0886b9801cc5059296512b77770 100644 (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;
        }
     }
index f96160e63fe572e44fd5e2c7b272c04160d01dc9..6a58b3db0e8d143394c2fb07ef96c41f70c1f94d 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2178,
 /**/
     2177,
 /**/