mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK: Allow creating a StringView from an empty ReadonlyBytes
An empty Span (and so ReadonlyBytes) can be created with a null data pointer, which is no longer allowed for StringView. Detect that case and use an empty string instead.
This commit is contained in:
committed by
Shannon Booth
parent
5a7ef7d494
commit
7781f1d131
Notes:
github-actions[bot]
2026-03-31 17:02:18 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/7781f1d1316 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8711 Reviewed-by: https://github.com/shannonbooth ✅
@@ -43,10 +43,9 @@ public:
|
||||
}
|
||||
|
||||
ALWAYS_INLINE StringView(ReadonlyBytes bytes)
|
||||
: m_characters(reinterpret_cast<char const*>(bytes.data()))
|
||||
: m_characters(bytes.is_empty() ? "" : reinterpret_cast<char const*>(bytes.data()))
|
||||
, m_length(bytes.size())
|
||||
{
|
||||
VERIFY(bytes.data() != nullptr);
|
||||
}
|
||||
|
||||
StringView(LIFETIME_BOUND ByteBuffer const&);
|
||||
|
||||
Reference in New Issue
Block a user