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>
This commit is contained in:

committed by
Junio C Hamano

parent
98c6d16d67
commit
aa9f618909
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user