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>
This commit is contained in:
parent
f7b47b273e
commit
078f8380f6
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user