From: Jonas Fonseca <fonseca@diku•dk>
To: git@vger•kernel.org
Cc: Junio C Hamano <junkio@cox•net>
Subject: [PATCH] branch: fix segfault when resolving an invalid HEAD
Date: Sun, 20 May 2007 14:19:17 +0200 [thread overview]
Message-ID: <20070520121917.GA18850@diku.dk> (raw)
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
next reply other threads:[~2007-05-20 12:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-20 12:19 Jonas Fonseca [this message]
2007-05-20 12:44 ` [PATCH] branch: fix segfault when resolving an invalid HEAD Jonas Fonseca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070520121917.GA18850@diku.dk \
--to=fonseca@diku$(echo .)dk \
--cc=git@vger$(echo .)kernel.org \
--cc=junkio@cox$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox