On Mon, Oct 10, 2022 at 11:11:05AM -0700, Junio C Hamano wrote: > Junio C Hamano <gitster@xxxxxxxxx> writes: > > So I think the right thing to do may be to allow free_pattern_expr() > to take and ignore NULL silently? Ah, that is already what you are > doing in the first hunk. Is this second hunk even necessary? Right. The fix in my patch is to have `free_pattern_expr()` treat its arguments like `free()` does, where NULL is a silent noop. We could do with or without the second hunk. I dropped it to avoid confusion, but it seems to have had the opposite effect ;-). I'll keep the if-statement there and instead drop the latter hunk. > I wonder how calls to grep.c::match_line() with opt->extended true > and opt->pattern_expression NULL, though. It should die() at the > beginning of match_expr_eval(), which probably is OK, but somehow > feels unsatisfactory. It does, and we can thank Linus for that: c922b01f54 (grep: fix segfault when "git grep '('" is given, 2009-04-27). Thanks, Taylor