Branch: refs/heads/webkitglib/2.52
Home: https://github.com/WebKit/WebKit
Commit: 7ed6b2faabe961a294681a0b800d302f63057a3e
https://github.com/WebKit/WebKit/commit/7ed6b2faabe961a294681a0b800d302f63057a3e
Author: Chris Dumez <[email protected]>
Date: 2026-03-25 (Wed, 25 Mar 2026)
Changed paths:
M Source/WTF/wtf/StdLibExtras.h
M Source/WTF/wtf/text/CStringView.h
M Tools/TestWebKitAPI/Tests/WTF/CStringView.cpp
Log Message:
-----------
Cherry-pick 309766@main (b416e36fff46).
https://bugs.webkit.org/show_bug.cgi?id=310514
Fix UB in equalSpans() and inconsistent null/empty semantics in CStringView
https://bugs.webkit.org/show_bug.cgi?id=310514
Reviewed by Anne van Kesteren.
equalSpans() calls memcmp() without guarding against zero-size spans.
However, passing nullptr to memcmp() is undefined behavior, even when
the count is zero. This was triggered when comparing null or
empty CStringViews via operator==.
Additionally, CStringView's ASCIILiteral constructor was collapsing
empty strings to null (`CStringView(""_s).isNull()` was true), while
`unsafeFromUTF8("")` and `fromUTF8({'\0'})` correctly preserved the
non-null empty state. Fix the ASCIILiteral constructor to stop
special-casing empty strings, making all construction paths consistent.
Test: Tools/TestWebKitAPI/Tests/WTF/CStringView.cpp
* Source/WTF/wtf/StdLibExtras.h:
(WTF::equalSpans): Add early return when both spans have size zero
to avoid calling memcmp() with potentially-null pointers.
* Source/WTF/wtf/text/CStringView.h:
* Tools/TestWebKitAPI/Tests/WTF/CStringView.cpp:
(TestWebKitAPI::TEST(WTF, CStringViewNullAndEmpty)):
(TestWebKitAPI::TEST(WTF, CStringViewSize)):
(TestWebKitAPI::TEST(WTF, CStringViewFrom)):
(TestWebKitAPI::TEST(WTF, CStringViewEquality)):
Canonical link: https://commits.webkit.org/309766@main
Canonical link: https://commits.webkit.org/305877.301@webkitglib/2.52
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications