mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Make Utf32View::substring_view() with 0 length not crash
Just make it hand out a zero-length Utf32View :^)
This commit is contained in:
parent
195c1784ba
commit
7207276697
Notes:
sideshowbarker
2024-07-19 06:29:59 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7207276697d
1 changed files with 3 additions and 0 deletions
|
@ -34,6 +34,7 @@ namespace AK {
|
|||
|
||||
class Utf32View {
|
||||
public:
|
||||
Utf32View() { }
|
||||
Utf32View(const u32* codepoints, size_t length)
|
||||
: m_codepoints(codepoints)
|
||||
, m_length(length)
|
||||
|
@ -46,6 +47,8 @@ public:
|
|||
|
||||
Utf32View substring_view(size_t offset, size_t length) const
|
||||
{
|
||||
if (length == 0)
|
||||
return {};
|
||||
ASSERT(offset < m_length);
|
||||
ASSERT(!Checked<size_t>::addition_would_overflow(offset, length));
|
||||
ASSERT((offset + length) <= m_length);
|
||||
|
|
Loading…
Reference in a new issue