summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-04-06 18:39:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-06 18:39:11 (GMT)
commitaad627e3c0e7dcf5a59da80cb424e8a4093b0324 (patch)
tree6de618e5e855a985e42e6020eff41c59123699e1 /builtin/merge.c
parenta6822e4172a8fa889b10a7a363088d2a05932b9b (diff)
parentb84e65d40929ec1146f54dcf4c9dbf8dc58467d0 (diff)
downloadgit-aad627e3c0e7dcf5a59da80cb424e8a4093b0324.zip
git-aad627e3c0e7dcf5a59da80cb424e8a4093b0324.tar.gz
git-aad627e3c0e7dcf5a59da80cb424e8a4093b0324.tar.bz2
Merge branch 'jv/merge-nothing-into-void'
"git merge FETCH_HEAD" dereferenced NULL pointer when merging nothing into an unborn history (which is arguably unusual usage, which perhaps was the reason why nobody noticed it). * jv/merge-nothing-into-void: merge: fix NULL pointer dereference when merging nothing into void
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index c8154aa..30b7bd5 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1258,12 +1258,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
builtin_merge_options);
if (!head_commit) {
- struct commit *remote_head;
/*
* If the merged head is a valid one there is no reason
* to forbid "git merge" into a branch yet to be born.
* We do the same for "git pull".
*/
+ unsigned char *remote_head_sha1;
if (squash)
die(_("Squash commit into empty head not supported yet"));
if (fast_forward == FF_NO)
@@ -1271,13 +1271,13 @@ 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)
die(_("%s - not something we can merge"), argv[0]);
if (remoteheads->next)
die(_("Can merge only exactly one commit into empty head"));
- read_empty(remote_head->object.oid.hash, 0);
- update_ref("initial pull", "HEAD", remote_head->object.oid.hash,
+ remote_head_sha1 = remoteheads->item->object.oid.hash;
+ read_empty(remote_head_sha1, 0);
+ update_ref("initial pull", "HEAD", remote_head_sha1,
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
goto done;
}