Commit 822af039 by Yong Li Committed by Carlos Martín Nieto

Do not call regfree() on an empty regex that is not successfully created by regcomp

(also removed an unused member "has_regex" from all_iter)
parent 1c01006b
...@@ -335,7 +335,6 @@ typedef struct { ...@@ -335,7 +335,6 @@ typedef struct {
git_config_iterator *current; git_config_iterator *current;
const git_config *cfg; const git_config *cfg;
regex_t regex; regex_t regex;
int has_regex;
size_t i; size_t i;
} all_iter; } all_iter;
...@@ -472,7 +471,6 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf ...@@ -472,7 +471,6 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) { if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&iter->regex, result); giterr_set_regex(&iter->regex, result);
regfree(&iter->regex);
git__free(iter); git__free(iter);
return -1; return -1;
} }
...@@ -895,7 +893,8 @@ void multivar_iter_free(git_config_iterator *_iter) ...@@ -895,7 +893,8 @@ void multivar_iter_free(git_config_iterator *_iter)
iter->iter->free(iter->iter); iter->iter->free(iter->iter);
git__free(iter->name); git__free(iter->name);
regfree(&iter->regex); if (iter->have_regex)
regfree(&iter->regex);
git__free(iter); git__free(iter);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment