summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2024-02-23 08:34:23 +0000
committerJunio C Hamano <gitster@pobox.com>2024-02-23 10:19:40 -0800
commitaa9f618909d30e3f0c7181243e89a81220507e6e (patch)
treeeba8780bfd3266fc0fc9371a0e9024d92d04b036 /cache-tree.c
parent98c6d16d6746059dc1e1183f8f8366eef2a41eff (diff)
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 'cache-tree.c')
-rw-r--r--cache-tree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 641427ed41..c6508b64a5 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -779,8 +779,8 @@ static void prime_cache_tree_rec(struct repository *r,
struct cache_tree_sub *sub;
struct tree *subtree = lookup_tree(r, &entry.oid);
- if (!subtree->object.parsed)
- parse_tree(subtree);
+ if (!subtree->object.parsed && parse_tree(subtree) < 0)
+ exit(128);
sub = cache_tree_sub(it, entry.path);
sub->cache_tree = cache_tree();