Merge branch 'ma/regex-no-regfree-after-comp-fail'

We used to call regfree() after regcomp() failed in some codepaths,
which have been corrected.

* ma/regex-no-regfree-after-comp-fail:
  regex: do not call `regfree()` if compilation fails
This commit is contained in:
Junio C Hamano 2018-05-30 21:51:28 +09:00
commit d89f1248aa
2 changed files with 0 additions and 3 deletions

View file

@ -215,7 +215,6 @@ static void regcomp_or_die(regex_t *regex, const char *needle, int cflags)
/* The POSIX.2 people are surely sick */
char errbuf[1024];
regerror(err, regex, errbuf, 1024);
regfree(regex);
die("invalid regex: %s", errbuf);
}
}

2
grep.c
View file

@ -636,7 +636,6 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)
if (err) {
char errbuf[1024];
regerror(err, &p->regexp, errbuf, sizeof(errbuf));
regfree(&p->regexp);
compile_regexp_failed(p, errbuf);
}
}
@ -701,7 +700,6 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
if (err) {
char errbuf[1024];
regerror(err, &p->regexp, errbuf, 1024);
regfree(&p->regexp);
compile_regexp_failed(p, errbuf);
}
}