diff --git a/components/input/input_router_impl.cc b/components/input/input_router_impl.cc index 2d3de8fbd6321..5702e56ef529e 100644 --- a/components/input/input_router_impl.cc +++ b/components/input/input_router_impl.cc @@ -151,7 +151,15 @@ void InputRouterImpl::SendKeyboardEvent( const NativeWebKeyboardEventWithLatencyInfo& key_event, KeyboardEventCallback event_result_callback, DispatchToRendererCallback& dispatch_callback) { + // StopFling() can synchronously emit a kGestureScrollEnd that re-enters the + // gesture pipeline and reaches the disposition handler, which may tear down + // the owning RenderInputRouter (and |this|). See the matching guard in + // OnTouchEventAck(). + auto weak_this = weak_ptr_factory_.GetWeakPtr(); gesture_event_queue_.StopFling(); + if (!weak_this) { + return; + } blink::mojom::WidgetInputHandler::DispatchEventCallback callback = base::BindOnce(&InputRouterImpl::KeyboardEventHandled, weak_this_, key_event, std::move(event_result_callback));