diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2024-02-23 09:34:23 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-23 19:19:40 +0100 |
commit | aa9f618909d30e3f0c7181243e89a81220507e6e (patch) | |
tree | eba8780bfd3266fc0fc9371a0e9024d92d04b036 /merge-ort.c | |
parent | t4301: verify that merge-tree fails on missing blob objects (diff) | |
download | git-aa9f618909d30e3f0c7181243e89a81220507e6e.tar.xz git-aa9f618909d30e3f0c7181243e89a81220507e6e.zip |
Always check `parse_tree*()`'s return value
Otherwise we may easily run into serious crashes: For example, if we run
`init_tree_desc()` directly after a failed `parse_tree()`, we are
accessing uninitialized data or trying to dereference `NULL`.
Note that the `parse_tree()` function already takes care of showing an
error message. The `parse_tree_indirectly()` and
`repo_get_commit_tree()` functions do not, therefore those latter call
sites need to show a useful error message while the former do not.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r-- | merge-ort.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/merge-ort.c b/merge-ort.c index 79d9e18f63..910ba38ff0 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4983,6 +4983,9 @@ redo: if (result->clean >= 0) { result->tree = parse_tree_indirect(&working_tree_oid); + if (!result->tree) + die(_("unable to read tree (%s)"), + oid_to_hex(&working_tree_oid)); /* existence of conflicted entries implies unclean */ result->clean &= strmap_empty(&opt->priv->conflicted); } |