aboutsummaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorMatt Kraai <kraai@ftbfs.org>2009-10-16 07:13:25 -0700
committerJunio C Hamano <gitster@pobox.com>2009-10-16 23:47:47 -0700
commitcfe370c6476392095bc3f18013d195b1cccd6184 (patch)
treea9f923388f0c478f01b06b3d33c5fbe0abeeeb36 /builtin-grep.c
parent0a0c342568458a15528778db1480dbbaa9a0b4d9 (diff)
downloadgit-cfe370c6476392095bc3f18013d195b1cccd6184.tar.gz
git-cfe370c6476392095bc3f18013d195b1cccd6184.tar.xz
grep: do not segfault when -f is used
"git grep" would segfault if its -f option was used because it would try to use an uninitialized strbuf, so initialize the strbuf. Thanks to Johannes Sixt <j.sixt@viscovery.net> for the help with the test cases. Signed-off-by: Matt Kraai <kraai@ftbfs.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index fd450bc16..e3b940b93 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -599,7 +599,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)