1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

Everywhere: Use OOM-safe ByteBuffer APIs where possible

If we can easily communicate failure, let's avoid asserting and report
failure instead.
This commit is contained in:
Ali Mohammad Pur 2021-09-06 03:28:46 +04:30 committed by Andreas Kling
parent 6606993432
commit 3a9f00c59b
22 changed files with 135 additions and 67 deletions

View file

@ -263,8 +263,10 @@ bool Parser::initialize_hint_tables()
auto total_size = primary_size + overflow_size;
possible_merged_stream_buffer = ByteBuffer::create_uninitialized(total_size);
possible_merged_stream_buffer.append(primary_hint_stream->bytes());
possible_merged_stream_buffer.append(overflow_hint_stream->bytes());
auto ok = possible_merged_stream_buffer.try_append(primary_hint_stream->bytes());
ok = ok && possible_merged_stream_buffer.try_append(overflow_hint_stream->bytes());
if (!ok)
return false;
hint_stream_bytes = possible_merged_stream_buffer.bytes();
} else {
hint_stream_bytes = primary_hint_stream->bytes();