mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibGfx: Handle OOM slightly better
When create_with_shared_buffer() is called in the next line, the RefPtr::operator* asserts that the RefPtr is not null. That can happen when we're low-ish on memory, and the image is huge.
This commit is contained in:
parent
31a3ed70f0
commit
ecb16f421d
Notes:
sideshowbarker
2024-07-19 01:02:33 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/ecb16f421d5 Pull-request: https://github.com/SerenityOS/serenity/pull/4334
1 changed files with 2 additions and 0 deletions
|
@ -345,6 +345,8 @@ RefPtr<Bitmap> Bitmap::to_bitmap_backed_by_shared_buffer() const
|
|||
if (m_shared_buffer)
|
||||
return *this;
|
||||
auto buffer = SharedBuffer::create_with_size(size_in_bytes());
|
||||
if (!buffer)
|
||||
return nullptr;
|
||||
auto bitmap = Bitmap::create_with_shared_buffer(m_format, *buffer, m_size, palette_to_vector());
|
||||
if (!bitmap)
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Reference in a new issue