vim-patch:8.0.1622: possible NULL pointer dereference

Problem:    Possible NULL pointer dereferencey. (Coverity)
Solution:   Reverse the check for a NULL pointer.
6ed86ad170
This commit is contained in:
Jan Edmund Lazo 2018-07-23 00:57:57 -04:00
parent 84b8612987
commit 6285b518d4

View File

@ -3603,15 +3603,16 @@ void ex_vimgrep(exarg_T *eap)
goto theend; goto theend;
} }
if (s != NULL && *s == NUL) { if (s == NULL || *s == NUL) {
/* Pattern is empty, use last search pattern. */ // Pattern is empty, use last search pattern.
if (last_search_pat() == NULL) { if (last_search_pat() == NULL) {
EMSG(_(e_noprevre)); EMSG(_(e_noprevre));
goto theend; goto theend;
} }
regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
} else } else {
regmatch.regprog = vim_regcomp(s, RE_MAGIC); regmatch.regprog = vim_regcomp(s, RE_MAGIC);
}
if (regmatch.regprog == NULL) if (regmatch.regprog == NULL)
goto theend; goto theend;