git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixing segmentation fault when merging FETCH_HEAD
@ 2016-03-19 18:17 Jose Ivan B. Vilarouca Filho
  2016-03-20  1:23 ` Eric Sunshine
  0 siblings, 1 reply; 6+ messages in thread
From: Jose Ivan B. Vilarouca Filho @ 2016-03-19 18:17 UTC (permalink / raw)
  To: git; +Cc: Jose Ivan B. Vilarouca Filho

From: "Jose Ivan B. Vilarouca Filho" <joseivan@lavid.ufpb.br>

A segmentaion fault is raised when trying to merge FETCH_HEAD
formed only by "not-for-merge" refs.

Ex:
    git init .
    git remote add origin ...
    git fetch origin
    git merge FETCH_HEAD

Signed-off-by: Jose Ivan B. Vilarouca Filho <joseivan@lavid.ufpb.br>
---
 builtin/merge.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 101ffef..7e419dc 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1270,9 +1270,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			    "an empty head"));
 		remoteheads = collect_parents(head_commit, &head_subsumed,
 					      argc, argv, NULL);
-		remote_head = remoteheads->item;
-		if (!remote_head)
+		if ((!remoteheads) || (!remoteheads->item))
 			die(_("%s - not something we can merge"), argv[0]);
+		remote_head = remoteheads->item;
 		if (remoteheads->next)
 			die(_("Can merge only exactly one commit into empty head"));
 		read_empty(remote_head->object.oid.hash, 0);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-21 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-19 18:17 [PATCH] Fixing segmentation fault when merging FETCH_HEAD Jose Ivan B. Vilarouca Filho
2016-03-20  1:23 ` Eric Sunshine
2016-03-21  0:11   ` Jose Ivan B. Vilarouca Filho
2016-03-21  6:40     ` Eric Sunshine
2016-03-21 19:01     ` merge: fix NULL pointer dereference when merging nothing into void Junio C Hamano
2016-03-21 19:36       ` Eric Sunshine

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).