* [PATCH] branch: fix segfault when resolving an invalid HEAD
@ 2007-05-20 12:19 Jonas Fonseca
2007-05-20 12:44 ` Jonas Fonseca
0 siblings, 1 reply; 2+ messages in thread
From: Jonas Fonseca @ 2007-05-20 12:19 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
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>
---
builtin-branch.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
Discovered while renaming a ref from "a/b" to "a" while redoing some
changes. After a `git push --all`, `git branch` in the remote repo
segfaulted, since its HEAD was still pointing to "a/b".
diff --git a/builtin-branch.c b/builtin-branch.c
index 6bd5843..a5b6bbe 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;
}
--
1.5.2.rc3.800.ga489e-dirty
--
Jonas Fonseca
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] branch: fix segfault when resolving an invalid HEAD
2007-05-20 12:19 [PATCH] branch: fix segfault when resolving an invalid HEAD Jonas Fonseca
@ 2007-05-20 12:44 ` Jonas Fonseca
0 siblings, 0 replies; 2+ messages in thread
From: Jonas Fonseca @ 2007-05-20 12:44 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
On 5/20/07, Jonas Fonseca <fonseca@diku.dk> wrote:
> Caused by return value of resolve_ref being passed directly
> to xstrdup whereby the sanity checking was never reached.
While checking other usage of resolve_ref, this problem also occurs in
builtin-show-branch.c around line 695, however, the logic later in the
file seems to be more forgiving so I have no idea of how to patch it.
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-20 12:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-20 12:19 [PATCH] branch: fix segfault when resolving an invalid HEAD Jonas Fonseca
2007-05-20 12:44 ` Jonas Fonseca
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.