summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorMatthew DeVore <matvore@google.com>2018-12-05 21:43:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-12-06 01:10:13 (GMT)
commit4cf67869b2ae3df7ab76b03c627f7b72d18d24ce (patch)
treea6e33d75471168a4f47d5237c36517879d40c16e /revision.c
parentc670b1f876521c9f7cd40184bf7ed05aad843433 (diff)
downloadgit-4cf67869b2ae3df7ab76b03c627f7b72d18d24ce.zip
git-4cf67869b2ae3df7ab76b03c627f7b72d18d24ce.tar.gz
git-4cf67869b2ae3df7ab76b03c627f7b72d18d24ce.tar.bz2
list-objects.c: don't segfault for missing cmdline objects
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. Properly handle --ignore-missing. If it is not passed, die when an object is missing. Otherwise, just silently ignore it. Signed-off-by: Matthew DeVore <matvore@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/revision.c b/revision.c
index b5108b7..07dc0e2 100644
--- a/revision.c
+++ b/revision.c
@@ -1717,6 +1717,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
if (!cant_be_filename)
verify_non_filename(revs->prefix, arg);
object = get_reference(revs, arg, &oid, flags ^ local_flags);
+ if (!object)
+ return revs->ignore_missing ? 0 : -1;
add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
add_pending_object_with_path(revs, object, arg, oc.mode, oc.path);
free(oc.path);