mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
AK: Ensure that we fill the whole String when reading from a Stream
This commit is contained in:
parent
5506951ffb
commit
9096b4d893
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;
|
u8* buffer = nullptr;
|
||||||
auto new_string_data = TRY(create_uninitialized(byte_count, buffer));
|
auto new_string_data = TRY(create_uninitialized(byte_count, buffer));
|
||||||
Bytes new_string_bytes = { buffer, byte_count };
|
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 });
|
Utf8View view(StringView { new_string_bytes });
|
||||||
if (!view.validate())
|
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) {
|
if (byte_count <= MAX_SHORT_STRING_BYTE_COUNT) {
|
||||||
ShortString short_string;
|
ShortString short_string;
|
||||||
if (byte_count > 0)
|
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;
|
short_string.byte_count_and_short_string_flag = (byte_count << 1) | SHORT_STRING_FLAG;
|
||||||
return String { short_string };
|
return String { short_string };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue