Title: [284456] trunk/Source/WTF
Revision
284456
Author
fpi...@apple.com
Date
2021-10-19 09:00:19 -0700 (Tue, 19 Oct 2021)

Log Message

StringBuffer should really know that strings might be 8-bit
https://bugs.webkit.org/show_bug.cgi?id=231937

Reviewed by Yusuke Suzuki.

We somehow forgot to change this to use CharType instead of UChar.

* wtf/text/StringBuffer.h:
(WTF::StringBuffer::resize):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (284455 => 284456)


--- trunk/Source/WTF/ChangeLog	2021-10-19 15:38:03 UTC (rev 284455)
+++ trunk/Source/WTF/ChangeLog	2021-10-19 16:00:19 UTC (rev 284456)
@@ -1,3 +1,15 @@
+2021-10-18  Filip Pizlo  <fpi...@apple.com>
+
+        StringBuffer should really know that strings might be 8-bit
+        https://bugs.webkit.org/show_bug.cgi?id=231937
+
+        Reviewed by Yusuke Suzuki.
+
+        We somehow forgot to change this to use CharType instead of UChar.
+
+        * wtf/text/StringBuffer.h:
+        (WTF::StringBuffer::resize):
+
 2021-10-19  Cameron McCormack  <hey...@apple.com>
 
         Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space

Modified: trunk/Source/WTF/wtf/text/StringBuffer.h (284455 => 284456)


--- trunk/Source/WTF/wtf/text/StringBuffer.h	2021-10-19 15:38:03 UTC (rev 284455)
+++ trunk/Source/WTF/wtf/text/StringBuffer.h	2021-10-19 16:00:19 UTC (rev 284456)
@@ -63,11 +63,8 @@
 
     void resize(unsigned newLength)
     {
-        if (newLength > m_length) {
-            if (newLength > std::numeric_limits<unsigned>::max() / sizeof(UChar))
-                CRASH();
-            m_data = static_cast<UChar*>(StringBufferMalloc::realloc(m_data, newLength * sizeof(UChar)));
-        }
+        if (newLength > m_length)
+            m_data = static_cast<CharType*>(StringBufferMalloc::realloc(m_data, Checked<size_t>(newLength) * sizeof(CharType)));
         m_length = newLength;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to