git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Matthew DeVore <matvore@google.com>
Cc: git@vger.kernel.org, jonathantanmy@google.com,
	jeffhost@microsoft.com, ramsay@ramsayjones.plus.com
Subject: Re: [PATCH v2] list-objects.c: don't segfault for missing cmdline objects
Date: Mon, 29 Oct 2018 09:06:28 +0900	[thread overview]
Message-ID: <xmqqo9bdaa63.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181025235314.63495-1-matvore@google.com> (Matthew DeVore's message of "Thu, 25 Oct 2018 16:53:14 -0700")

Matthew DeVore <matvore@google.com> writes:

> When a command is invoked with both --exclude-promisor-objects,
> --objects-edge-aggressive, and a missing object on the command line,
> the rev_info.cmdline array could get a NULL pointer for the value of
> an 'item' field. Prevent dereferencing of a NULL pointer in that
> situation.

Thanks.

> There are a few other places in the code where rev_info.cmdline is read
> and the code doesn't handle NULL objects, but I couldn't prove to myself
> that any of them needed to change except this one (since it may not
> actually be possible to reach the other code paths with
> rev_info.cmdline[] set to NULL).
>
> Signed-off-by: Matthew DeVore <matvore@google.com>
> ---
>  list-objects.c           | 3 ++-
>  t/t0410-partial-clone.sh | 6 +++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/list-objects.c b/list-objects.c
> index c41cc80db5..27ed2c6cab 100644
> --- a/list-objects.c
> +++ b/list-objects.c
> @@ -245,7 +245,8 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
>  		for (i = 0; i < revs->cmdline.nr; i++) {
>  			struct object *obj = revs->cmdline.rev[i].item;
>  			struct commit *commit = (struct commit *)obj;
> -			if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
> +			if (!obj || obj->type != OBJ_COMMIT ||
> +			    !(obj->flags & UNINTERESTING))
>  				continue;
>  			mark_tree_uninteresting(revs->repo,
>  						get_commit_tree(commit));
> diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
> index ba3887f178..e52291e674 100755
> --- a/t/t0410-partial-clone.sh
> +++ b/t/t0410-partial-clone.sh
> @@ -366,7 +366,11 @@ test_expect_success 'rev-list accepts missing and promised objects on command li
>  
>  	git -C repo config core.repositoryformatversion 1 &&
>  	git -C repo config extensions.partialclone "arbitrary string" &&
> -	git -C repo rev-list --exclude-promisor-objects --objects "$COMMIT" "$TREE" "$BLOB"
> +
> +	git -C repo rev-list --objects \
> +		--exclude-promisor-objects "$COMMIT" "$TREE" "$BLOB" &&
> +	git -C repo rev-list --objects-edge-aggressive \
> +		--exclude-promisor-objects "$COMMIT" "$TREE" "$BLOB"
>  '
>  
>  test_expect_success 'gc repacks promisor objects separately from non-promisor objects' '

  reply	other threads:[~2018-10-29  0:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 21:57 [PATCH] revision.c: drop missing objects from cmdline Matthew DeVore
2018-10-24  4:54 ` Junio C Hamano
2018-10-25 23:13   ` Matthew DeVore
2018-10-25 23:53 ` [PATCH v2] list-objects.c: don't segfault for missing cmdline objects Matthew DeVore
2018-10-29  0:06   ` Junio C Hamano [this message]
2018-12-05 21:43 ` [PATCH v3] " Matthew DeVore
2018-12-06  1:12   ` Junio C Hamano

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=xmqqo9bdaa63.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.com \
    --cc=matvore@google.com \
    --cc=ramsay@ramsayjones.plus.com \
    /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).