Commit e34ae84a authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

Fix ASan WidgetTest.WidgetDestroyedItselfDoesNotCrash crash.

This makes sure WidgetTest.WidgetDestroyedItselfDoesNotCrash test does NOT
crash with use-after-free ASan error in ChromeOS and Mac. Test was added in
https://chromium-review.googlesource.com/c/chromium/src/+/1145261/ and only
covered Windows and Linux.

Bug: 878314

Change-Id: Ifde7f402955bd34bfd0618e4f67c52feeb333624
Reviewed-on: https://chromium-review.googlesource.com/1193283
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586678}
parent 6699fd7e
......@@ -895,8 +895,12 @@ void NativeWidgetAura::OnWindowDestroying(aura::Window* window) {
void NativeWidgetAura::OnWindowDestroyed(aura::Window* window) {
window_ = NULL;
// |OnNativeWidgetDestroyed| may delete |this| if the object does not own
// itself.
bool should_delete_this =
(ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET);
delegate_->OnNativeWidgetDestroyed();
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
if (should_delete_this)
delete this;
}
......
......@@ -114,8 +114,12 @@ void NativeWidgetMac::WindowDestroying() {
void NativeWidgetMac::WindowDestroyed() {
DCHECK(bridge());
bridge_host_.reset();
// |OnNativeWidgetDestroyed| may delete |this| if the object does not own
// itself.
bool should_delete_this =
(ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET);
delegate_->OnNativeWidgetDestroyed();
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
if (should_delete_this)
delete this;
}
......
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