Commit 29297bc6 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Fix potential leak in RWHV unit tests

MockWidgetInputHandler destruction may in some cases spin a RunLoop,
which in turn may allow certain Mojo objects to do work that (unsafely)
modifies the state of that same MockWidgetInputHandler. To prevent this
from happening, this CL explicitly closes the handler's Binding before
proceeding with the rest of the handler's destruction.

Bug: 872063
Change-Id: I9c40455ac0182fbc435a0c2edfcf707aa18c94c8
Reviewed-on: https://chromium-review.googlesource.com/c/1294712Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#601800}
parent 87c85020
...@@ -24,7 +24,12 @@ MockWidgetInputHandler::MockWidgetInputHandler( ...@@ -24,7 +24,12 @@ MockWidgetInputHandler::MockWidgetInputHandler(
mojom::WidgetInputHandlerHostPtr host) mojom::WidgetInputHandlerHostPtr host)
: binding_(this, std::move(request)), host_(std::move(host)) {} : binding_(this, std::move(request)), host_(std::move(host)) {}
MockWidgetInputHandler::~MockWidgetInputHandler() {} MockWidgetInputHandler::~MockWidgetInputHandler() {
// We explicitly close the binding before the tearing down the vector of
// messages, as some of them may spin a RunLoop on destruction and we don't
// want to accept more messages beyond this point.
binding_.Close();
}
void MockWidgetInputHandler::SetFocus(bool focused) { void MockWidgetInputHandler::SetFocus(bool focused) {
dispatched_messages_.emplace_back( dispatched_messages_.emplace_back(
......
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