From 7cd17e80579c2bffd6245837175a6e1b12a78045 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Sep 2015 17:02:54 -0400 Subject: show-branch: avoid segfault with --reflog of unborn branch 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 Signed-off-by: Junio C Hamano --- builtin/show-branch.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtin/show-branch.c') diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 408ce70307..092b59b0b3 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"); -- cgit v1.2.3