summaryrefslogtreecommitdiff
path: root/builtin-branch.c
diff options
context:
space:
mode:
authorJonas Fonseca <fonseca@diku.dk>2007-05-20 14:19:17 +0200
committerJunio C Hamano <junkio@cox.net>2007-05-20 14:39:16 -0700
commit078f8380f65acfdffee077a642e982453277873a (patch)
treebb9be48e03ab0a6bb71336af32dc99429a2da351 /builtin-branch.c
parentf7b47b273ed2c9e9b298c4f5dd02884b46dfbced (diff)
downloadgit-078f8380f65acfdffee077a642e982453277873a.tar.gz
branch: fix segfault when resolving an invalid HEAD
Caused by return value of resolve_ref being passed directly to xstrdup whereby the sanity checking was never reached. Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r--builtin-branch.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index 7408285050..8956d0f842 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -623,9 +623,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
(rename && force_create))
usage(builtin_branch_usage);
- head = xstrdup(resolve_ref("HEAD", head_sha1, 0, NULL));
+ head = resolve_ref("HEAD", head_sha1, 0, NULL);
if (!head)
die("Failed to resolve HEAD as a valid ref.");
+ head = xstrdup(head);
if (!strcmp(head, "HEAD")) {
detached = 1;
}