git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jose Ivan B. Vilarouca Filho" <joseivan@lavid.ufpb.br>,
	Git List <git@vger.kernel.org>
Subject: Re: merge: fix NULL pointer dereference when merging nothing into void
Date: Mon, 21 Mar 2016 15:36:45 -0400	[thread overview]
Message-ID: <CAPig+cQjt==AKTWfCk6kzgVciGVb9XtKNiwPK14nPM7=4yhmjQ@mail.gmail.com> (raw)
In-Reply-To: <xmqq7fgvmz8o.fsf_-_@gitster.mtv.corp.google.com>

On Mon, Mar 21, 2016 at 3:01 PM, Junio C Hamano <gitster@pobox.com> wrote:
> When we are on an unborn branch and merging only one foreign parent,
> we allow "git merge" to fast-forward to that foreign parent commit.
>
> This codepath incorrectly attempted to dereference the list of
> parents that the merge is going to record even when the list is
> empty.  It must refuse to operate instead when there is no parent.
>
> All other codepaths make sure the list is not empty before they
> dereference it, and are safe.
>
> Reported by Jose Ivan B. Vilarouca Filho
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
> @@ -725,4 +725,14 @@ test_expect_success 'merge detects mod-256 conflicts (resolve)' '
> +test_expect_success 'merge nothing into void' '
> +       git init void &&
> +       (
> +               cd void &&
> +               git remote add up .. &&
> +               git fetch up &&
> +               test_must_fail git merge FETCH_HEAD

Ah, nice. I either didn't know or had forgotten that test_must_fail is
smart enough to detect unexpected failures (such as segfault), so my
advice to Jose about capturing stderr[1] was misdirected. Thanks.

[1]: http://article.gmane.org/gmane.comp.version-control.git/289405

> +       )
> +'
> +
>  test_done

      reply	other threads:[~2016-03-21 19:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cQjt==AKTWfCk6kzgVciGVb9XtKNiwPK14nPM7=4yhmjQ@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=joseivan@lavid.ufpb.br \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).