mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibGfx: Fail gracefully when trying to load invalid-sized HiDPI image
This commit is contained in:
parent
592a51855c
commit
c8183f2651
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue