summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Bitmap.cpp
diff options
context:
space:
mode:
authorMaciej <sppmacd@pm.me>2022-02-01 23:29:05 +0100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-02-05 23:28:06 +0200
commitc8183f26519ea3184075c502f80e6fdcf072d927 (patch)
tree0c0343c04a2f12ded0c25aeb657905586dd7878c /Userland/Libraries/LibGfx/Bitmap.cpp
parent592a51855c385797fc98342be89b5d334b793c71 (diff)
downloadserenity-c8183f26519ea3184075c502f80e6fdcf072d927.zip
LibGfx: Fail gracefully when trying to load invalid-sized HiDPI image
Diffstat (limited to 'Userland/Libraries/LibGfx/Bitmap.cpp')
-rw-r--r--Userland/Libraries/LibGfx/Bitmap.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp
index 5beed09611..211acd229a 100644
--- a/Userland/Libraries/LibGfx/Bitmap.cpp
+++ b/Userland/Libraries/LibGfx/Bitmap.cpp
@@ -117,8 +117,8 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::try_load_from_file(String const& path, in
auto fd = TRY(Core::System::open(highdpi_icon_string, O_RDONLY));
auto bitmap = TRY(try_load_from_fd_and_close(fd, highdpi_icon_string));
- VERIFY(bitmap->width() % scale_factor == 0);
- VERIFY(bitmap->height() % scale_factor == 0);
+ if (bitmap->width() % scale_factor != 0 || bitmap->height() % scale_factor != 0)
+ return Error::from_string_literal("Bitmap::try_load_from_file: HighDPI image size should be divisible by scale factor");
bitmap->m_size.set_width(bitmap->width() / scale_factor);
bitmap->m_size.set_height(bitmap->height() / scale_factor);
bitmap->m_scale = scale_factor;