From: Jonas Fonseca Date: Sun, 20 May 2007 12:19:17 +0000 (+0200) Subject: branch: fix segfault when resolving an invalid HEAD X-Git-Tag: v1.5.2.1~23^2~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=078f8380f65acfdffee077a642e982453277873a;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin-branch.c b/builtin-branch.c index 740828505..8956d0f84 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; }