Title: [209074] trunk/Source/WTF
Revision
209074
Author
[email protected]
Date
2016-11-29 09:18:03 -0800 (Tue, 29 Nov 2016)

Log Message

REGRESSION (r209058): API test StringBuilderTest.Equal crashing
https://bugs.webkit.org/show_bug.cgi?id=165142

* wtf/text/StringBuilder.h: Added an overload of the equal function just
for the case where the arguments are StringBuilder, String. This is needed
because of the peculiar behavior of is8Bit in String, different from any of
our other string classes. I think we should consider changing String::is8Bit
to return true for null strings. We could then remove this overload and
probably remove other checks for null and zero length elsewhere that are
also needed only to avoid calling is8Bit on a null String.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (209073 => 209074)


--- trunk/Source/WTF/ChangeLog	2016-11-29 17:16:08 UTC (rev 209073)
+++ trunk/Source/WTF/ChangeLog	2016-11-29 17:18:03 UTC (rev 209074)
@@ -1,3 +1,16 @@
+2016-11-29  Darin Adler  <[email protected]>
+
+        REGRESSION (r209058): API test StringBuilderTest.Equal crashing
+        https://bugs.webkit.org/show_bug.cgi?id=165142
+
+        * wtf/text/StringBuilder.h: Added an overload of the equal function just
+        for the case where the arguments are StringBuilder, String. This is needed
+        because of the peculiar behavior of is8Bit in String, different from any of
+        our other string classes. I think we should consider changing String::is8Bit
+        to return true for null strings. We could then remove this overload and
+        probably remove other checks for null and zero length elsewhere that are
+        also needed only to avoid calling is8Bit on a null String.
+
 2016-11-29  Wenson Hsieh  <[email protected]>
 
         Scroll snapping on Mac should use AppKit animations

Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (209073 => 209074)


--- trunk/Source/WTF/wtf/text/StringBuilder.h	2016-11-29 17:16:08 UTC (rev 209073)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h	2016-11-29 17:18:03 UTC (rev 209074)
@@ -300,6 +300,7 @@
 };
 
 template<typename StringType> bool equal(const StringBuilder&, const StringType&);
+bool equal(const StringBuilder&, const String&); // Only needed because is8Bit dereferences nullptr when the string is null.
 template<typename CharacterType> bool equal(const StringBuilder&, const CharacterType*, unsigned length);
 
 bool operator==(const StringBuilder&, const StringBuilder&);
@@ -325,6 +326,11 @@
     return equalCommon(a, b);
 }
 
+inline bool equal(const StringBuilder& a, const String& b)
+{
+    return !b.isNull() && equalCommon(a, b);
+}
+
 inline bool operator==(const StringBuilder& a, const StringBuilder& b) { return equal(a, b); }
 inline bool operator!=(const StringBuilder& a, const StringBuilder& b) { return !equal(a, b); }
 inline bool operator==(const StringBuilder& a, const String& b) { return equal(a, b); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to