[PATCH 01/68] show-branch: avoid segfault with --reflog of unborn branch
- From
Jeff King <peff@peff.net>
- Date
- Sep 24, 2015, 21:02 UTC
- Message-ID
- <20150924210253.GA30744@sigill.intra.peff.net>
- In-Reply-To
- <20150924210225.GA23624@sigill.intra.peff.net>
When no branch is given to the "--reflog" option, we resolve HEAD to get the default branch. However, if HEAD points to an unborn branch, resolve_ref returns NULL, and we later segfault trying to access it.
Signed-off-by: Jeff King <peff@peff.net> --- builtin/show-branch.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 408ce70..092b59b 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -743,6 +743,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) fake_av[1] = NULL; av = fake_av; ac = 1; + if (!*av) + die("no branches given, and HEAD is not valid"); } if (ac != 1) die("--reflog option needs one branch name");
-- 2.6.0.rc3.454.g204ad51