LibWeb: Don't crash when setting offscreen canvas size to 0

Previously, this would crash because `Gfx::Bitmap` can't have a zero
size.
This commit is contained in:
Tim Ledbetter 2025-07-01 01:19:08 +01:00 committed by Sam Atkins
parent f882c446cb
commit 5413716802
Notes: github-actions[bot] 2025-07-04 15:11:48 +00:00
5 changed files with 78 additions and 18 deletions

View file

@ -45,6 +45,11 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi
[&source_width, &source_height](GC::Root<OffscreenCanvas> const& source) {
auto const bitmap = source->bitmap();
if (!bitmap) {
source_width = 0;
source_height = 0;
return;
}
source_width = bitmap->width();
source_height = bitmap->height();
},