Title: [165664] trunk/Source/WebKit/mac
Revision
165664
Author
rn...@webkit.org
Date
2014-03-14 16:55:30 -0700 (Fri, 14 Mar 2014)

Log Message

REGRESSION(r165385): [WebTextIterator currentRange] crashes
https://bugs.webkit.org/show_bug.cgi?id=130271

Reviewed by Anders Carlsson.

After r165385, TextIterator::range no longer checked the nullity of m_positionNode. As a result,
[WebTextIterator currentRange] which simply calls TextIterator::range crashes when an application
that embeds WebKit doesn't check [WebTextIterator atEnd] first.

Preserve the old public API behavior by checking atEnd in [WebTextIterator currentRange].

* WebView/WebTextIterator.mm:
(-[WebTextIterator currentRange]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (165663 => 165664)


--- trunk/Source/WebKit/mac/ChangeLog	2014-03-14 23:53:36 UTC (rev 165663)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-03-14 23:55:30 UTC (rev 165664)
@@ -1,3 +1,19 @@
+2014-03-14  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION(r165385): [WebTextIterator currentRange] crashes
+        https://bugs.webkit.org/show_bug.cgi?id=130271
+
+        Reviewed by Anders Carlsson.
+
+        After r165385, TextIterator::range no longer checked the nullity of m_positionNode. As a result,
+        [WebTextIterator currentRange] which simply calls TextIterator::range crashes when an application
+        that embeds WebKit doesn't check [WebTextIterator atEnd] first.
+
+        Preserve the old public API behavior by checking atEnd in [WebTextIterator currentRange].
+
+        * WebView/WebTextIterator.mm:
+        (-[WebTextIterator currentRange]):
+
 2014-03-12  Sergio Villar Senin  <svil...@igalia.com>
 
         Rename DEFINE_STATIC_LOCAL to DEPRECATED_DEFINE_STATIC_LOCAL

Modified: trunk/Source/WebKit/mac/WebView/WebTextIterator.mm (165663 => 165664)


--- trunk/Source/WebKit/mac/WebView/WebTextIterator.mm	2014-03-14 23:53:36 UTC (rev 165663)
+++ trunk/Source/WebKit/mac/WebView/WebTextIterator.mm	2014-03-14 23:55:30 UTC (rev 165664)
@@ -88,7 +88,10 @@
 
 - (DOMRange *)currentRange
 {
-    return kit(_private->_textIterator->range().get());
+    WebCore::TextIterator& textIterator = *_private->_textIterator;
+    if (textIterator.atEnd())
+        return nullptr;
+    return kit(textIterator.range().get());
 }
 
 // FIXME: Consider deprecating this method and creating one that does not require copying 8-bit characters.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to