Skip to content

grep: tolerate NULL argument to free_grep_expr()

Taylor Blau git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2t4202: demonstrate `git log --invert-grep` segfaultt/t4202-log.sh+6 -00 replies
2/2grep.c: tolerate NULL grep_expr in free_pattern_expr()grep.c t/t4202-log.sh+4 -34 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] grep: tolerate NULL argument to free_grep_expr()

This short series demonstrates and fixes a bug whereby a NULL struct grep_expr* argument (such as when running git log --invert-grep without a --grep argument) could cause us to segfault when trying to dereference that argument.

An alternative approach is to disallow --invert-grep without a --grep argument. But a more user-friendly approach is to permit this combination by pretending as if neither argument was given. This patch series takes the latter approach by teaching free_grep_expr() that passing a NULL argument should result in a noop, not a segfault.

Taylor Blau (2):
t4202: demonstrate git log --invert-grep segfault grep.c: tolerate NULL grep_expr in free_pattern_expr()

 grep.c         | 5 +++--
 t/t4202-log.sh | 6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.37.0.1.g1379af2e9d