diff --git a/ui/ozone/platform/x11/x11_window.cc b/ui/ozone/platform/x11/x11_window.cc index 70f25eaa3d605..4744f19b87575 100644 --- a/ui/ozone/platform/x11/x11_window.cc +++ b/ui/ozone/platform/x11/x11_window.cc @@ -1469,13 +1469,22 @@ void X11Window::DispatchUiEvent(ui::Event* event, const x11::Event& xev) { // event's location and dispatch to the other. const gfx::Point target_origin = located_events_grabber->GetBoundsInPixels().origin(); + // GetBoundsInPixels() may dispatch X server replies synchronously and + // run OnBoundsChanged on the grabber, which can destroy either `this` + // or the grabber. Re-check both. if (!weak_this) { return; } + if (window_manager->located_events_grabber() != located_events_grabber) { + return; + } const gfx::Point current_origin = GetBoundsInPixels().origin(); if (!weak_this) { return; } + if (window_manager->located_events_grabber() != located_events_grabber) { + return; + } ConvertEventLocationToTargetWindowLocation(target_origin, current_origin, event->AsLocatedEvent()); }