fix_potential_draggable_region_crash_when_no_mainframeimpl.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Shelley Vohr <[email protected]>
  3. Date: Thu, 1 Aug 2024 15:30:32 +0200
  4. Subject: Fix potential draggable region crash when no MainFrameImpl
  5. Fix a crash that can occur when SetSupportsDraggableRegions
  6. is called with `true` and there is no MainFrameImpl. When MainFrameImpl
  7. is nullptr, logic currently correctly returns early, but
  8. supports_draggable_regions_ is set before that happens. As a
  9. result, when SupportsDraggableRegions() is called, it will return
  10. true, and thus LocalFrameView::UpdateDocumentDraggableRegions() will
  11. call DraggableRegionsChanged(). This will trigger a crash in
  12. WebViewImpl::DraggableRegionsChanged(), as it assumes that
  13. MainFrameImpl is not null.
  14. Upstreamed in https://chromium-review.googlesource.com/c/chromium/src/+/5756619
  15. diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
  16. index 9469c6be9f58b2805d0bfafa189785264ad839c5..4d42d8d676b7f12abb41c1de98f5f6f0f8d88688 100644
  17. --- a/third_party/blink/renderer/core/exported/web_view_impl.cc
  18. +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
  19. @@ -4084,11 +4084,12 @@ bool WebViewImpl::IsFencedFrameRoot() const {
  20. }
  21. void WebViewImpl::SetSupportsDraggableRegions(bool supports_draggable_regions) {
  22. - supports_draggable_regions_ = supports_draggable_regions;
  23. if (!MainFrameImpl() || !MainFrameImpl()->GetFrame()) {
  24. return;
  25. }
  26. + supports_draggable_regions_ = supports_draggable_regions;
  27. +
  28. LocalFrame* local_frame = MainFrameImpl()->GetFrame();
  29. if (supports_draggable_regions_) {