Skip to content

Commit

Permalink
branch: fix segfault when resolving an invalid HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jonas authored and Junio C Hamano committed May 20, 2007
1 parent f7b47b2 commit 078f838
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 078f838

Please sign in to comment.