mirror of
https://github.com/RGBCube/serenity
synced 2025-06-17 19:42:10 +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
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…
Add table
Add a link
Reference in a new issue