range-diff: avoid segfault with -I
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>
René Scharfe committed
Sep 4, 2021 at 09:50 UTC
709b3f32d333df1e29dbb073b4e9e834f130a989
1 file changed
+3
range-diff.c
+3
@@ -485,6 +485,7 @@ static void output(struct string_list *a, struct string_list *b,
485
else
486
diff_setup(&opts);
487
488
+ opts.no_free = 1;
489
if (!opts.output_format)
490
opts.output_format = DIFF_FORMAT_PATCH;
491
opts.flags.suppress_diff_headers = 1;
@@ -545,6 +546,8 @@ static void output(struct string_list *a, struct string_list *b,
546
strbuf_release(&buf);
547
strbuf_release(&dashes);
548
strbuf_release(&indent);
549
+ opts.no_free = 0;
550
+ diff_free(&opts);
551
}
552
553
int show_range_diff(const char *range1, const char *range2,