Skip to contentSkip to conversation

git log: avoid segfault with --all-match

PATCH In review Michele Ballabio 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git log: avoid segfault with --all-match

Avoid a segfault when the command

	git log --all-match

was issued.

---

Not sure if this is the right fix, nor if it would be better a warning or an error.

 grep.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
grep.c +2 -1
index 062b2b6..cb4666d 100644
@@ -190,7 +190,8 @@ void compile_grep_patterns(struct grep_opt *opt)
 	 * A classic recursive descent parser would do.
 	 */
 	p = opt->pattern_list;
-	opt->pattern_expression = compile_pattern_expr(&p);
+	if (p)
+		opt->pattern_expression = compile_pattern_expr(&p);
 	if (p)
 		die("incomplete pattern expression: %s", p->pattern);
 }
Signature · 1 line
1.6.2.22.gc2ac
#1 lore raw
Quoted 11 lines · Michele Ballabio

Avoid a segfault when the command

	git log --all-match

was issued.

---

Not sure if this is the right fix, nor if it would be better a warning or an error.

I think ignoring it makes sense; you could alias "git log --all-match" to something like "git lg", and when no grepping option appears it will still work.

I'd add s/was issued./was issued, by ignoring the option/; or something like that, though.

#2 lore raw

PATCH v2 1/1 git log: avoid segfault with --all-match

Avoid a segfault when the command

	git log --all-match

was issued, by ignoring the option.

---
 grep.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
grep.c +2 -1
index 062b2b6..cb4666d 100644
@@ -190,7 +190,8 @@ void compile_grep_patterns(struct grep_opt *opt)
 	 * A classic recursive descent parser would do.
 	 */
 	p = opt->pattern_list;
-	opt->pattern_expression = compile_pattern_expr(&p);
+	if (p)
+		opt->pattern_expression = compile_pattern_expr(&p);
 	if (p)
 		die("incomplete pattern expression: %s", p->pattern);
 }
Signature · 1 line
1.6.2.22.gc2ac