Title: [276485] trunk/Source/WTF
- Revision
- 276485
- Author
- [email protected]
- Date
- 2021-04-22 22:06:43 -0700 (Thu, 22 Apr 2021)
Log Message
[WTF] Undefined behavior warning in StringBuilder::allocateBuffer
https://bugs.webkit.org/show_bug.cgi?id=224942
Reviewed by Chris Dumez.
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::allocateBuffer): Add check before calling memcpy
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (276484 => 276485)
--- trunk/Source/WTF/ChangeLog 2021-04-23 03:56:57 UTC (rev 276484)
+++ trunk/Source/WTF/ChangeLog 2021-04-23 05:06:43 UTC (rev 276485)
@@ -1,3 +1,13 @@
+2021-04-22 Lauro Moura <[email protected]>
+
+ [WTF] Undefined behavior warning in StringBuilder::allocateBuffer
+ https://bugs.webkit.org/show_bug.cgi?id=224942
+
+ Reviewed by Chris Dumez.
+
+ * wtf/text/StringBuilder.cpp:
+ (WTF::StringBuilder::allocateBuffer): Add check before calling memcpy
+
2021-04-22 Simon Fraser <[email protected]>
Add trace points for WKWebView snapshotting
Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (276484 => 276485)
--- trunk/Source/WTF/wtf/text/StringBuilder.cpp 2021-04-23 03:56:57 UTC (rev 276484)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp 2021-04-23 05:06:43 UTC (rev 276485)
@@ -112,8 +112,10 @@
auto buffer = StringImpl::tryCreateUninitialized(requiredLength, m_bufferCharacters8);
if (UNLIKELY(!buffer))
return didOverflow();
- std::memcpy(m_bufferCharacters8, currentCharacters, m_length.unsafeGet());
-
+
+ if (m_length)
+ std::memcpy(m_bufferCharacters8, currentCharacters, m_length.unsafeGet());
+
// Update the builder state.
m_buffer = WTFMove(buffer);
m_string = String();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes