Skip to content

Commit

Permalink
(iOS) Dragging the selection in Live Text far away sometimes causes a…
Browse files Browse the repository at this point in the history
… crash

https://bugs.webkit.org/show_bug.cgi?id=255566
rdar://108169157

Reviewed by Wenson Hsieh.

When selecting text with Live Text, if the selection contains different writing modes, a crash
can occur when collecting the selection geometries if the ancestor does not have a renderer.

This PR fixes this by adding a null check for the existence of a renderer.

* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::collectSelectionGeometriesInternal):

Canonical link: https://commits.webkit.org/263053@main
  • Loading branch information
rr-codes committed Apr 18, 2023
1 parent a6b2a57 commit f7dc489
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/WebCore/rendering/RenderObject.cpp
Expand Up @@ -2410,8 +2410,10 @@ auto RenderObject::collectSelectionGeometriesInternal(const SimpleRange& range)
// The range could span nodes with different writing modes.
// If this is the case, we use the writing mode of the common ancestor.
if (containsDifferentWritingModes) {
if (auto ancestor = commonInclusiveAncestor<ComposedTree>(range))
hasFlippedWritingMode = ancestor->renderer()->style().isFlippedBlocksWritingMode();
if (auto ancestor = commonInclusiveAncestor<ComposedTree>(range)) {
if (auto* renderer = ancestor->renderer())
hasFlippedWritingMode = renderer->style().isFlippedBlocksWritingMode();
}
}

auto numberOfGeometries = geometries.size();
Expand Down

0 comments on commit f7dc489

Please sign in to comment.