From: Davide Berardi <berardi.dav@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Segmentation fault on non-commit objects.
Date: Tue, 29 Oct 2019 10:27:35 +0100 [thread overview]
Message-ID: <20191029092735.GA84120@carpenter.lan> (raw)
Fixed segmentation fault that can be triggered using
$ git clone --branch $object $repository
with object pointing to a non-commit (e.g. a blob).
Signed-off-by: Davide Berardi <berardi.dav@gmail.com>
---
builtin/clone.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/builtin/clone.c b/builtin/clone.c
index f665b28ccc..6ad2d8fe77 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -720,6 +720,9 @@ static void update_head(const struct ref *our, const struct ref *remote,
} else if (our) {
struct commit *c = lookup_commit_reference(the_repository,
&our->old_oid);
+ /* Check if --branch specifies a non-commit. */
+ if (c == NULL)
+ die(_("unable to update HEAD (cannot find commit)"));
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NO_DEREF,
UPDATE_REFS_DIE_ON_ERR);
--
2.23.0
next reply other threads:[~2019-10-29 9:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 9:27 Davide Berardi [this message]
2019-10-29 13:11 ` [PATCH] Segmentation fault on non-commit objects Johannes Schindelin
2019-11-01 0:26 ` Davide Berardi
2019-10-29 14:06 ` Jeff King
2019-10-30 2:44 ` Junio C Hamano
2019-10-31 5:37 ` Jeff King
2019-10-31 10:43 ` Davide Berardi
2019-11-01 0:29 ` Davide Berardi
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=20191029092735.GA84120@carpenter.lan \
--to=berardi.dav@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).