Merge branch 'ab/diff-deferred-free'

A small memleak in "diff -I<regexp>" has been corrected.

* ab/diff-deferred-free:
  diff: plug memory leak from regcomp() on {log,diff} -I
  diff: add an API for deferred freeing
This commit is contained in:
Junio C Hamano
2021-02-22 16:12:43 -08:00
4 changed files with 60 additions and 20 deletions

View File

@ -963,12 +963,14 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
int log_tree_commit(struct rev_info *opt, struct commit *commit)
{
struct log_info log;
int shown, close_file = opt->diffopt.close_file;
int shown;
/* maybe called by e.g. cmd_log_walk(), maybe stand-alone */
int no_free = opt->diffopt.no_free;
log.commit = commit;
log.parent = NULL;
opt->loginfo = &log;
opt->diffopt.close_file = 0;
opt->diffopt.no_free = 1;
if (opt->line_level_traverse)
return line_log_print(opt, commit);
@ -985,7 +987,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
opt->loginfo = NULL;
maybe_flush_or_die(opt->diffopt.file, "stdout");
if (close_file)
fclose(opt->diffopt.file);
opt->diffopt.no_free = no_free;
diff_free(&opt->diffopt);
return shown;
}