From 143443e0b6412cd7f5a702e5b190bea60da733fe Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 24 Jul 2021 22:49:48 +0200 Subject: LibGfx: Make Gfx::Bitmap::set_nonvolatile() report allocation failure Making a bitmap non-volatile after being volatile may fail to allocate physical pages after the kernel stole the old pages in a purge. This is different from the pages being purged, but reallocated. In that case, they are simply replaced with zero-fill-on-demand pages as if they were freshly allocated. --- Userland/Libraries/LibWeb/Loader/ImageResource.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries/LibWeb/Loader') diff --git a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp index 1261559464..508bd62ba6 100644 --- a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp +++ b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp @@ -97,8 +97,9 @@ void ImageResource::update_volatility() if (!frame.bitmap) { still_has_decoded_image = false; } else { - bool still_has_frame = frame.bitmap->set_nonvolatile(); - if (!still_has_frame) + bool was_purged = false; + bool bitmap_has_memory = frame.bitmap->set_nonvolatile(was_purged); + if (!bitmap_has_memory || was_purged) still_has_decoded_image = false; } } -- cgit v1.2.3