Skip to content

Commit

Permalink
patch 8.1.0194: possibly use of NULL pointer
Browse files Browse the repository at this point in the history
Problem:    Possibly use of NULL pointer. (Coverity)
Solution:   Reset the re_in_use flag earlier.
  • Loading branch information
brammool committed Jul 18, 2018
1 parent ca4cc01 commit 4149980
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/regexp.c
Expand Up @@ -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
Expand All @@ -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);
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -789,6 +789,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
194,
/**/
193,
/**/
Expand Down

0 comments on commit 4149980

Please sign in to comment.