mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 17:45:59 +01:00
Fix UAF in animation end callback if callback deletes the animation (#2389)
Removes use after free when the end callback deletes the animation as long as `m_bRemoveEndAfterRan` is false.
This commit is contained in:
parent
438d063ec6
commit
409ff027f8
1 changed files with 3 additions and 1 deletions
|
@ -268,8 +268,10 @@ class CAnimatedVariable {
|
||||||
// methods
|
// methods
|
||||||
void onAnimationEnd() {
|
void onAnimationEnd() {
|
||||||
if (m_fEndCallback) {
|
if (m_fEndCallback) {
|
||||||
|
// loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false.
|
||||||
|
auto removeEndCallback = m_bRemoveEndAfterRan;
|
||||||
m_fEndCallback(this);
|
m_fEndCallback(this);
|
||||||
if (m_bRemoveEndAfterRan)
|
if (removeEndCallback)
|
||||||
m_fEndCallback = nullptr; // reset
|
m_fEndCallback = nullptr; // reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue