mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 17:12:51 +00:00
Fix use-after-free in submodule reload
If the first call to release a no-longer-existent submodule freed the object, the check if a second is needed would dereference the data that was just freed.
This commit is contained in:
parent
041fad4aac
commit
add8db06f9
@ -852,10 +852,13 @@ int git_submodule_reload_all(git_repository *repo, int force)
|
|||||||
git_strmap_foreach_value(repo->submodules, sm, {
|
git_strmap_foreach_value(repo->submodules, sm, {
|
||||||
git_strmap *cache = repo->submodules;
|
git_strmap *cache = repo->submodules;
|
||||||
|
|
||||||
if ((sm->flags & GIT_SUBMODULE_STATUS__IN_FLAGS) == 0) {
|
if (sm && (sm->flags & GIT_SUBMODULE_STATUS__IN_FLAGS) == 0) {
|
||||||
submodule_cache_remove_item(cache, sm->name, sm, true);
|
/* we must check path != name before first remove, in case
|
||||||
|
* that call frees the submodule */
|
||||||
|
bool free_as_path = (sm->path != sm->name);
|
||||||
|
|
||||||
if (sm->path != sm->name)
|
submodule_cache_remove_item(cache, sm->name, sm, true);
|
||||||
|
if (free_as_path)
|
||||||
submodule_cache_remove_item(cache, sm->path, sm, true);
|
submodule_cache_remove_item(cache, sm->path, sm, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user