Fix use-after free in ase_ungroup_all()

Anyway this code is not used anymore, it was for v1.1 when v1.1 and
v1.2 branches were developed at the same time (layer groups feature
was added in v1.2, so v1.1 just moved groups children to the root).
This commit is contained in:
David Capello 2024-02-27 13:20:13 -03:00
parent 52afc9e9a7
commit 7aca017a58

View File

@ -1696,8 +1696,12 @@ static void ase_ungroup_all(LayerGroup* group)
for (Layer* child : list) {
if (child->isGroup()) {
ase_ungroup_all(static_cast<LayerGroup*>(child));
group->removeLayer(child);
auto* childGroup = static_cast<LayerGroup*>(child);
ase_ungroup_all(childGroup);
group->removeLayer(childGroup);
ASSERT(childGroup->layersCount() == 0);
delete childGroup;
}
else if (group != root) {
// Create a new name adding all group layer names
@ -1715,11 +1719,6 @@ static void ase_ungroup_all(LayerGroup* group)
root->addLayer(child);
}
}
if (group != root) {
ASSERT(group->layersCount() == 0);
delete group;
}
}
} // namespace app