AK: Explicitly check for null data in Utf16View

The underlying CPU-specific instructions for operating on UTF-16 strings
behave differently for null inputs. Add an explicit check for this state
for consistency.
This commit is contained in:
Timothy Flynn 2024-07-20 07:31:19 -04:00 committed by Andreas Kling
commit 74d644a216
Notes: github-actions[bot] 2024-07-21 17:58:00 +00:00
3 changed files with 34 additions and 0 deletions

View file

@ -49,6 +49,8 @@ ErrorOr<String> String::from_utf16(Utf16View const& utf16)
{
if (!utf16.validate())
return Error::from_string_literal("String::from_utf16: Input was not valid UTF-16");
if (utf16.is_empty())
return String {};
String result;