mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Fix 64-bit alignment issue in shared-superstring substrings
Thanks to Timothy Flynn for the test! Fixes #17141
This commit is contained in:
parent
ba5df46a49
commit
d0697d350d
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d0697d350d Pull-request: https://github.com/SerenityOS/serenity/pull/17520 Issue: https://github.com/SerenityOS/serenity/issues/17141 Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 12 additions and 1 deletions
|
@ -77,7 +77,7 @@ private:
|
|||
bool m_substring { false };
|
||||
bool m_is_fly_string { false };
|
||||
|
||||
u8 m_bytes_or_substring_data[0];
|
||||
alignas(SubstringData) u8 m_bytes_or_substring_data[0];
|
||||
};
|
||||
|
||||
void StringData::operator delete(void* ptr)
|
||||
|
|
|
@ -97,6 +97,17 @@ TEST_CASE(substring)
|
|||
EXPECT_EQ(long_substring, "Hello I am"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(substring_with_shared_superstring)
|
||||
{
|
||||
auto superstring = MUST(String::from_utf8("Hello I am a long string"sv));
|
||||
|
||||
auto substring1 = MUST(superstring.substring_from_byte_offset_with_shared_superstring(0, 5));
|
||||
EXPECT_EQ(substring1, "Hello"sv);
|
||||
|
||||
auto substring2 = MUST(superstring.substring_from_byte_offset_with_shared_superstring(0, 10));
|
||||
EXPECT_EQ(substring2, "Hello I am"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(code_points)
|
||||
{
|
||||
auto string = MUST(String::from_utf8("🦬🪒"sv));
|
||||
|
|
Loading…
Reference in a new issue