mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Don't return a null Utf32View when a zero-length one is requested
There is still an offset to consider, a zero-length view is very different from a nonexistent string :P Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
parent
2f754013a1
commit
0060fa48d4
Notes:
sideshowbarker
2024-07-18 08:47:57 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/0060fa48d41 Pull-request: https://github.com/SerenityOS/serenity/pull/8847 Reviewed-by: https://github.com/MaxWipfli Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/trflynn89
1 changed files with 1 additions and 3 deletions
|
@ -94,9 +94,7 @@ public:
|
||||||
|
|
||||||
Utf32View substring_view(size_t offset, size_t length) const
|
Utf32View substring_view(size_t offset, size_t length) const
|
||||||
{
|
{
|
||||||
if (length == 0)
|
VERIFY(offset <= m_length);
|
||||||
return {};
|
|
||||||
VERIFY(offset < m_length);
|
|
||||||
VERIFY(!Checked<size_t>::addition_would_overflow(offset, length));
|
VERIFY(!Checked<size_t>::addition_would_overflow(offset, length));
|
||||||
VERIFY((offset + length) <= m_length);
|
VERIFY((offset + length) <= m_length);
|
||||||
return Utf32View(m_code_points + offset, length);
|
return Utf32View(m_code_points + offset, length);
|
||||||
|
|
Loading…
Reference in a new issue