log: fix memory leak in open_next_file()
Noticed-by: Jeff King <peff@peff.net> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
f7566f073f
commit
15d980a785
|
@ -842,8 +842,10 @@ static int open_next_file(struct commit *commit, const char *subject,
|
||||||
if (output_directory) {
|
if (output_directory) {
|
||||||
strbuf_addstr(&filename, output_directory);
|
strbuf_addstr(&filename, output_directory);
|
||||||
if (filename.len >=
|
if (filename.len >=
|
||||||
PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len)
|
PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len) {
|
||||||
|
strbuf_release(&filename);
|
||||||
return error(_("name of output directory is too long"));
|
return error(_("name of output directory is too long"));
|
||||||
|
}
|
||||||
strbuf_complete(&filename, '/');
|
strbuf_complete(&filename, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,9 +859,11 @@ static int open_next_file(struct commit *commit, const char *subject,
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
printf("%s\n", filename.buf + outdir_offset);
|
printf("%s\n", filename.buf + outdir_offset);
|
||||||
|
|
||||||
if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL)
|
if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) {
|
||||||
return error_errno(_("Cannot open patch file %s"),
|
error_errno(_("Cannot open patch file %s"), filename.buf);
|
||||||
filename.buf);
|
strbuf_release(&filename);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
strbuf_release(&filename);
|
strbuf_release(&filename);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue