git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] push: fix segfault when HEAD points nowhere

From
Fraser Tweedale <frase@frase.id.au>
Date
Jan 31, 2013, 12:22 UTC
Message-ID
<1359634971-79036-1-git-send-email-frase@frase.id.au>

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
Next: Junio C Hamano
Message 1 of 2 in “push: fix segfault when HEAD points nowhere”
  1. push: fix segfault when HEAD points nowhereFraser Tweedale, Jan 31, 2013
  2. Junio C HamanoJan 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.