]> git.ipfire.org Git - thirdparty/git.git/commitdiff
range-diff: avoid segfault with -I
authorRené Scharfe <l.s.r@web.de>
Sat, 4 Sep 2021 07:50:58 +0000 (09:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Sep 2021 20:03:13 +0000 (13:03 -0700)
output() reuses the same struct diff_options for multiple calls of
diff_flush().  Set the option no_free to instruct it to keep the
ignore regexes between calls and release them explicitly at the end.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
range-diff.c

index e9479794b46a51fd08b8ed287a50f35b7c92a4d5..a315c4c8894b7ed569a6af84dae7b69e5a4612f9 100644 (file)
@@ -485,6 +485,7 @@ static void output(struct string_list *a, struct string_list *b,
        else
                diff_setup(&opts);
 
+       opts.no_free = 1;
        if (!opts.output_format)
                opts.output_format = DIFF_FORMAT_PATCH;
        opts.flags.suppress_diff_headers = 1;
@@ -545,6 +546,8 @@ static void output(struct string_list *a, struct string_list *b,
        strbuf_release(&buf);
        strbuf_release(&dashes);
        strbuf_release(&indent);
+       opts.no_free = 0;
+       diff_free(&opts);
 }
 
 int show_range_diff(const char *range1, const char *range2,