diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-02-21 23:02:48 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2023-02-21 22:28:15 -0700 |
commit | 9096b4d8938b53431053cad801db8a12f9d7cb90 (patch) | |
tree | 1f579847632a4012fc608006fa71b2c07ef54f80 /AK | |
parent | 5506951ffb1c5f4195c77c6b245fa4f8916dd257 (diff) | |
download | serenity-9096b4d8938b53431053cad801db8a12f9d7cb90.zip |
AK: Ensure that we fill the whole String when reading from a Stream
Diffstat (limited to 'AK')
-rw-r--r-- | AK/String.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/AK/String.cpp b/AK/String.cpp index e87e0c290a..15a5dafc09 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -151,7 +151,7 @@ ErrorOr<NonnullRefPtr<StringData>> StringData::from_stream(Stream& stream, size_ u8* buffer = nullptr; auto new_string_data = TRY(create_uninitialized(byte_count, buffer)); Bytes new_string_bytes = { buffer, byte_count }; - TRY(stream.read(new_string_bytes)); + TRY(stream.read_entire_buffer(new_string_bytes)); Utf8View view(StringView { new_string_bytes }); if (!view.validate()) @@ -246,7 +246,7 @@ ErrorOr<String> String::from_stream(Stream& stream, size_t byte_count) if (byte_count <= MAX_SHORT_STRING_BYTE_COUNT) { ShortString short_string; if (byte_count > 0) - TRY(stream.read({ short_string.storage, byte_count })); + TRY(stream.read_entire_buffer({ short_string.storage, byte_count })); short_string.byte_count_and_short_string_flag = (byte_count << 1) | SHORT_STRING_FLAG; return String { short_string }; } |