diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-10-28 01:09:46 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-10-28 01:09:46 +0300 |
commit | ae84e924dafbaf1eb907065e9fc9c246acb2c265 (patch) | |
tree | f1772106851cabdd043098b30250c62a1c712d6d /builtin | |
parent | 63e52739d272278d89dc9f2a78d1f9887ef28732 (diff) | |
parent | 5eb2ed691b809a55b024b8c10739254ea2ac48b7 (diff) |
Merge branch 'rs/tighten-callers-of-deref-tag'
Code clean-up.
* rs/tighten-callers-of-deref-tag:
line-log: handle deref_tag() returning NULL
blame: handle deref_tag() returning NULL
grep: handle deref_tag() returning NULL
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/blame.c | 2 | ||||
-rw-r--r-- | builtin/grep.c | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index bb0f29300e..b5036ab327 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata) if (kind != OBJ_TAG) return -1; obj = deref_tag(r, parse_object(r, &oid), NULL, 0); + if (!obj) + return -1; oidcpy(&oid, &obj->oid); } } diff --git a/builtin/grep.c b/builtin/grep.c index c8037388c6..e58e57504c 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -670,6 +670,17 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, NULL, 0); obj_read_unlock(); + if (!real_obj) { + char hex[GIT_MAX_HEXSZ + 1]; + const char *name = list->objects[i].name; + + if (!name) { + oid_to_hex_r(hex, &list->objects[i].item->oid); + name = hex; + } + die(_("invalid object '%s' given."), name); + } + /* load the gitmodules file for this rev */ if (recurse_submodules) { submodule_free(opt->repo); |