]> granicus.if.org Git - vim/commitdiff
patch 8.1.0194: possibly use of NULL pointer v8.1.0194
authorBram Moolenaar <Bram@vim.org>
Wed, 18 Jul 2018 04:02:09 +0000 (06:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 18 Jul 2018 04:02:09 +0000 (06:02 +0200)
Problem:    Possibly use of NULL pointer. (Coverity)
Solution:   Reset the re_in_use flag earlier.

src/regexp.c
src/version.c

index 88cf8817ab4e61e0a454573d7babefc8be9cc14a..9d7350b6ed9b7f9d9bd567cfeac915315faba1bb 100644 (file)
@@ -8266,6 +8266,7 @@ vim_regexec_string(
     rex.reg_endpos = NULL;
 
     result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);
+    rmp->regprog->re_in_use = FALSE;
 
     /* NFA engine aborted because it's very slow. */
     if (rmp->regprog->re_engine == AUTOMATIC_ENGINE
@@ -8284,7 +8285,11 @@ vim_regexec_string(
 #endif
            rmp->regprog = vim_regcomp(pat, re_flags);
            if (rmp->regprog != NULL)
+           {
+               rmp->regprog->re_in_use = TRUE;
                result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);
+               rmp->regprog->re_in_use = FALSE;
+           }
            vim_free(pat);
        }
 
@@ -8294,7 +8299,6 @@ vim_regexec_string(
     rex_in_use = rex_in_use_save;
     if (rex_in_use)
        rex = rex_save;
-    rmp->regprog->re_in_use = FALSE;
 
     return result > 0;
 }
@@ -8382,6 +8386,7 @@ vim_regexec_multi(
 
     result = rmp->regprog->engine->regexec_multi(
                                      rmp, win, buf, lnum, col, tm, timed_out);
+    rmp->regprog->re_in_use = FALSE;
 
     /* NFA engine aborted because it's very slow. */
     if (rmp->regprog->re_engine == AUTOMATIC_ENGINE
@@ -8409,8 +8414,12 @@ vim_regexec_multi(
 #endif
 
            if (rmp->regprog != NULL)
+           {
+               rmp->regprog->re_in_use = TRUE;
                result = rmp->regprog->engine->regexec_multi(
                                      rmp, win, buf, lnum, col, tm, timed_out);
+               rmp->regprog->re_in_use = FALSE;
+           }
            vim_free(pat);
        }
        p_re = save_p_re;
@@ -8419,7 +8428,6 @@ vim_regexec_multi(
     rex_in_use = rex_in_use_save;
     if (rex_in_use)
        rex = rex_save;
-    rmp->regprog->re_in_use = FALSE;
 
     return result <= 0 ? 0 : result;
 }
index 3c9676e517b5c86d87a28f8fa7824a51f5d63344..f6542b672a8029a8b6d2a21a28931ca95837dc43 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    194,
 /**/
     193,
 /**/