mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Ensure that we fill the whole String when reading from a Stream
This commit is contained in:
parent
5506951ffb
commit
9096b4d893
Notes:
sideshowbarker
2024-07-17 00:16:31 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/9096b4d893 Pull-request: https://github.com/SerenityOS/serenity/pull/17565
1 changed files with 2 additions and 2 deletions
|
@ -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 };
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue