mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-08 03:25:38 +00:00
tree-cache: Don't segfault upon corruption
This commit is contained in:
parent
82e6a42c6c
commit
3d5233455b
@ -178,9 +178,12 @@ void git_tree_cache_free(git_tree_cache *tree)
|
||||
if (tree == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < tree->children_count; ++i)
|
||||
git_tree_cache_free(tree->children[i]);
|
||||
if (tree->children != NULL) {
|
||||
for (i = 0; i < tree->children_count; ++i)
|
||||
git_tree_cache_free(tree->children[i]);
|
||||
|
||||
git__free(tree->children);
|
||||
}
|
||||
|
||||
git__free(tree->children);
|
||||
git__free(tree);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ static const size_t index_entry_count_2 = 1437;
|
||||
#define TEST_INDEX_PATH cl_fixture("testrepo.git/index")
|
||||
#define TEST_INDEX2_PATH cl_fixture("gitgit.index")
|
||||
#define TEST_INDEXBIG_PATH cl_fixture("big.index")
|
||||
#define TEST_INDEXBAD_PATH cl_fixture("bad.index")
|
||||
|
||||
|
||||
/* Suite data */
|
||||
@ -535,3 +536,11 @@ void test_index_tests__reload_from_disk(void)
|
||||
git_index_free(write_index);
|
||||
git_repository_free(repo);
|
||||
}
|
||||
|
||||
void test_index_tests__corrupted_extension(void)
|
||||
{
|
||||
/* sort the entires in an empty index */
|
||||
git_index *index;
|
||||
|
||||
cl_git_fail_with(git_index_open(&index, TEST_INDEXBAD_PATH), GIT_ERROR);
|
||||
}
|
||||
|
||||
BIN
tests/resources/bad.index
Normal file
BIN
tests/resources/bad.index
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user