"git grep" would segfault if its -f option was used because it would try to use an uninitialized strbuf, so initialize the strbuf. Signed-off-by: Matt Kraai <kraai@xxxxxxxxx> --- builtin-grep.c | 2 +- t/t7002-grep.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index 761799d..1df25b0 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -631,7 +631,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset) struct grep_opt *grep_opt = opt->value; FILE *patterns; int lno = 0; - struct strbuf sb; + struct strbuf sb = STRBUF_INIT; patterns = fopen(arg, "r"); if (!patterns) diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index ae56a36..762f815 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -44,6 +44,10 @@ test_expect_success 'grep should not segfault with a bad input' ' test_must_fail git grep "(" ' +test_expect_success 'grep should not segfault with -f' ' + test_must_fail git grep -f /dev/null +' + for H in HEAD '' do case "$H" in -- 1.6.5 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html