LibWeb/Animations: Keep a safe copy of associated animations

The associated animations list might be modified on the time change
event. This means that we can't safely iterate over the hashmap during
this period.

This fixes a crash in:
 - css/css-animations/CSSAnimation-effect.tentative.html
This commit is contained in:
Lucas CHOLLET 2024-12-27 16:10:18 -05:00 committed by Andreas Kling
parent 906b7bf4e3
commit 43c30e4f7b
Notes: github-actions[bot] 2024-12-30 10:05:55 +00:00

View file

@ -24,8 +24,12 @@ void AnimationTimeline::set_current_time(Optional<double> value)
}
m_current_time = value;
for (auto& animation : m_associated_animations)
// The loop might modify the content of m_associated_animations, so let's iterate over a copy.
auto temporary_copy = GC::RootVector<GC::Ref<Animation>>(vm().heap());
temporary_copy.extend(m_associated_animations.values());
for (auto& animation : temporary_copy) {
animation->notify_timeline_time_did_change();
}
}
void AnimationTimeline::set_associated_document(GC::Ptr<DOM::Document> document)