Thread (80 messages) flat view 80 messages, 6 authors, 2016-06-15
STALE3740d

[PATCH 01/68] show-branch: avoid segfault with --reflog of unborn branch

From: Jeff King <hidden>
Date: 2016-06-15 23:06:40
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help