mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:47:34 +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:
parent
6606993432
commit
3a9f00c59b
22 changed files with 135 additions and 67 deletions
|
@ -135,7 +135,8 @@ ByteBuffer BMPWriter::dump(const RefPtr<Bitmap> bitmap, DibHeader dib_header)
|
|||
}
|
||||
}
|
||||
|
||||
buffer.append(pixel_data.data(), pixel_data.size());
|
||||
if (!buffer.try_append(pixel_data.data(), pixel_data.size()))
|
||||
dbgln("Failed to write {} bytes of pixel data to buffer", pixel_data.size());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,7 @@ PNGChunk::PNGChunk(String type)
|
|||
|
||||
void PNGChunk::store_type()
|
||||
{
|
||||
for (auto character : type()) {
|
||||
m_data.append(&character, sizeof(character));
|
||||
}
|
||||
m_data.append(type().bytes());
|
||||
}
|
||||
|
||||
void PNGChunk::store_data_length()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue