]> granicus.if.org Git - vim/commitdiff
patch 8.2.2181: valgrind warnings for using uninitialized value v8.2.2181
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 17:24:00 +0000 (18:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Dec 2020 17:24:00 +0000 (18:24 +0100)
Problem:    Valgrind warnings for using uninitialized value.
Solution:   Do not use "start" or "end" unless there is a match.

src/regexp_bt.c
src/regexp_nfa.c
src/version.c

index 476f34ef4027680e9bae61616aa512c75405bf71..2960bad945fec469d9651118b26f970c01ebc777 100644 (file)
@@ -4805,21 +4805,24 @@ theend:
     if (backpos.ga_maxlen > BACKPOS_INITIAL)
        ga_clear(&backpos);
 
-    // Make sure the end is never before the start.  Can happen when \zs and
-    // \ze are used.
-    if (REG_MULTI)
+    if (retval > 0)
     {
-       lpos_T *start = &rex.reg_mmatch->startpos[0];
-       lpos_T *end = &rex.reg_mmatch->endpos[0];
+       // Make sure the end is never before the start.  Can happen when \zs
+       // and \ze are used.
+       if (REG_MULTI)
+       {
+           lpos_T *start = &rex.reg_mmatch->startpos[0];
+           lpos_T *end = &rex.reg_mmatch->endpos[0];
 
-       if (end->lnum < start->lnum
+           if (end->lnum < start->lnum
                        || (end->lnum == start->lnum && end->col < start->col))
-           rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
-    }
-    else
-    {
-       if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
-           rex.reg_match->endp[0] = rex.reg_match->startp[0];
+               rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
+       }
+       else
+       {
+           if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
+               rex.reg_match->endp[0] = rex.reg_match->startp[0];
+       }
     }
 
     return retval;
index 6182f58cdb42b33034efa4b348a37c2a0c8e61df..ad47142d6a201156a3e81c4945e6a6cedba358a9 100644 (file)
@@ -7227,21 +7227,24 @@ nfa_regexec_both(
 #endif
 
 theend:
-    // Make sure the end is never before the start.  Can happen when \zs and
-    // \ze are used.
-    if (REG_MULTI)
+    if (retval > 0)
     {
-       lpos_T *start = &rex.reg_mmatch->startpos[0];
-       lpos_T *end = &rex.reg_mmatch->endpos[0];
+       // Make sure the end is never before the start.  Can happen when \zs and
+       // \ze are used.
+       if (REG_MULTI)
+       {
+           lpos_T *start = &rex.reg_mmatch->startpos[0];
+           lpos_T *end = &rex.reg_mmatch->endpos[0];
 
-       if (end->lnum < start->lnum
+           if (end->lnum < start->lnum
                        || (end->lnum == start->lnum && end->col < start->col))
-           rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
-    }
-    else if (retval > 0)
-    {
-       if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
-           rex.reg_match->endp[0] = rex.reg_match->startp[0];
+               rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
+       }
+       else
+       {
+           if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
+               rex.reg_match->endp[0] = rex.reg_match->startp[0];
+       }
     }
 
     return retval;
index 07edd0c9e6004423b5e0ba3439efef6320ca7d23..04951e46d458cfbde47d619bef3fddce0bd43956 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2181,
 /**/
     2180,
 /**/