Reviewers: loyso, dstockwell,
Message:
please take a look.
Description:
When cancelling an animation, add missing timeline-detach check.
Speculative fix for fuzzer-reported null derefence on cancel().
R=
BUG=491847
Please review this at
https://codereview.chromium.org/1154423006/
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Affected files (+16, -1 lines):
A LayoutTests/web-animations-api/animation-timeline-detached-no-crash.html
M Source/core/animation/Animation.cpp
Index:
LayoutTests/web-animations-api/animation-timeline-detached-no-crash.html
diff --git
a/LayoutTests/web-animations-api/animation-timeline-detached-no-crash.html
b/LayoutTests/web-animations-api/animation-timeline-detached-no-crash.html
new file mode 100644
index
0000000000000000000000000000000000000000..46e569e3172c14ee2162d389330faade4be42d26
--- /dev/null
+++
b/LayoutTests/web-animations-api/animation-timeline-detached-no-crash.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<script>
+test(function() {
+ var doc = document.implementation.createDocument("", "", null);
+ doc.createElement("div").animate([], 1000);
+ var anim = doc.timeline.getAnimations()[0];
+ doc = null;
+ gc();
+ anim.cancel();
+}, 'Calling cancel() on an animation detached from its timeline should not
crash.');
+</script>
Index: Source/core/animation/Animation.cpp
diff --git a/Source/core/animation/Animation.cpp
b/Source/core/animation/Animation.cpp
index
8e1e3d64816ef2671ff01bfd0e8e3761ac3d8b53..5103120d88fef661182dd039d0726bcd241fb484
100644
--- a/Source/core/animation/Animation.cpp
+++ b/Source/core/animation/Animation.cpp
@@ -836,7 +836,8 @@ void Animation::cancel()
m_startTime = nullValue();
m_currentTimePending = false;
- InspectorInstrumentation::didCancelAnimation(timeline()->document(),
this);
+ if (timeline())
+
InspectorInstrumentation::didCancelAnimation(timeline()->document(), this);
}
void Animation::beginUpdatingState()