diff options
author | Matthew DeVore <matvore@google.com> | 2018-12-05 22:43:46 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-12-06 02:10:13 +0100 |
commit | 4cf67869b2ae3df7ab76b03c627f7b72d18d24ce (patch) | |
tree | a6e33d75471168a4f47d5237c36517879d40c16e /revision.c | |
parent | Sixth batch for 2.20 (diff) | |
download | git-4cf67869b2ae3df7ab76b03c627f7b72d18d24ce.tar.xz git-4cf67869b2ae3df7ab76b03c627f7b72d18d24ce.zip |
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.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/revision.c b/revision.c index b5108b75ab..07dc0e28b6 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); |