Git development
 help / color / mirror / Atom feed
From: Fraser Tweedale <frase@frase.id.au>
To: git@vger.kernel.org
Cc: Fraser Tweedale <frase@frase.id.au>
Subject: [PATCH] push: fix segfault when HEAD points nowhere
Date: Thu, 31 Jan 2013 22:22:51 +1000	[thread overview]
Message-ID: <1359634971-79036-1-git-send-email-frase@frase.id.au> (raw)

When reporting the outcome of a push, a segfault occurs if HEAD does
not point somewhere.  Check that HEAD points somewhere before trying
to strcmp it.

Signed-off-by: Fraser Tweedale <frase@frase.id.au>
---
 transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/transport.c b/transport.c
index 9932f40..b9306ef 100644
--- a/transport.c
+++ b/transport.c
@@ -741,7 +741,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
 			n += print_one_push_status(ref, dest, n, porcelain);
 		if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
 		    *nonfastforward != NON_FF_HEAD) {
-			if (!strcmp(head, ref->name))
+			if (head != NULL && !strcmp(head, ref->name))
 				*nonfastforward = NON_FF_HEAD;
 			else
 				*nonfastforward = NON_FF_OTHER;
-- 
1.8.1.1

             reply	other threads:[~2013-01-31 12:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 12:22 Fraser Tweedale [this message]
2013-01-31 16:06 ` [PATCH] push: fix segfault when HEAD points nowhere Junio C Hamano

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=1359634971-79036-1-git-send-email-frase@frase.id.au \
    --to=frase@frase.id.au \
    --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