Skip to content

Commit

Permalink
Do not call regfree() on an empty regex that is not successfully crea…
Browse files Browse the repository at this point in the history
…ted by regcomp

(also removed an unused member "has_regex" from all_iter)
  • Loading branch information
Yong Li authored and carlosmn committed May 18, 2015
1 parent 1c01006 commit 822af03
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/config.c
Expand Up @@ -335,7 +335,6 @@ typedef struct {
git_config_iterator *current;
const git_config *cfg;
regex_t regex;
int has_regex;
size_t i;
} all_iter;

Expand Down Expand Up @@ -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) {
giterr_set_regex(&iter->regex, result);
regfree(&iter->regex);
git__free(iter);
return -1;
}
Expand Down Expand Up @@ -895,7 +893,8 @@ void multivar_iter_free(git_config_iterator *_iter)
iter->iter->free(iter->iter);

git__free(iter->name);
regfree(&iter->regex);
if (iter->have_regex)
regfree(&iter->regex);
git__free(iter);
}

Expand Down

0 comments on commit 822af03

Please sign in to comment.