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

Re: merge: fix NULL pointer dereference when merging nothing into void

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 21, 2016, 19:36 UTC
Message-ID
<CAPig+cQjt==AKTWfCk6kzgVciGVb9XtKNiwPK14nPM7=4yhmjQ@mail.gmail.com>
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:
Show 22 quoted lines
> 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
Previous: Junio C Hamano
Message 6 of 6 in “Fixing segmentation fault when merging FETCH_HEAD”
  1. Fixing segmentation fault when merging FETCH_HEADJose Ivan B. Vilarouca Filho, Mar 19, 2016
  2. Eric SunshineMar 20, 2016
  3. Jose Ivan B. Vilarouca FilhoMar 21, 2016
  4. Eric SunshineMar 21, 2016
  5. merge: fix NULL pointer dereference when merging nothing into voidJunio C Hamano, Mar 21, 2016
  6. Eric SunshineMar 21, 2016

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.