From 709b3f32d333df1e29dbb073b4e9e834f130a989 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 4 Sep 2021 09:50:58 +0200 Subject: [PATCH] range-diff: avoid segfault with -I MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- range-diff.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/range-diff.c b/range-diff.c index e9479794b4..a315c4c889 100644 --- a/range-diff.c +++ b/range-diff.c @@ -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, -- 2.39.2