Commit b739e83f authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Add pre-finalizer to SpeechSynthesisUtterance.

Avoids a UAF by disconnecting the mojo::Receiver from the pre-finalizer.

Bug: 1043603
Change-Id: I1592a517bf74dd4fcb8e947e1122442864e0dacc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2042276Reviewed-by: default avatarDarin Fisher <darin@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739140}
parent d4a6fbc8
......@@ -142,6 +142,10 @@ void SpeechSynthesisUtterance::Start(SpeechSynthesis* synthesis) {
&SpeechSynthesisUtterance::OnDisconnected, WrapWeakPersistent(this)));
}
void SpeechSynthesisUtterance::Dispose() {
receiver_.reset();
}
void SpeechSynthesisUtterance::OnDisconnected() {
// If the remote end disconnects, just simulate that we finished normally.
if (!finished_)
......
......@@ -42,6 +42,7 @@ class SpeechSynthesisUtterance final
public ContextClient,
public mojom::blink::SpeechSynthesisClient {
DEFINE_WRAPPERTYPEINFO();
USING_PRE_FINALIZER(SpeechSynthesisUtterance, Dispose);
USING_GARBAGE_COLLECTED_MIXIN(SpeechSynthesisUtterance);
public:
......@@ -106,6 +107,10 @@ class SpeechSynthesisUtterance final
void Start(SpeechSynthesis* synthesis);
private:
// USING_PRE_FINALIZER interface.
// Called before the object gets garbage collected.
void Dispose();
void OnDisconnected();
// EventTarget
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment