mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 17:02:56 +00:00
LibWeb: Fix division by zero on a zero-width viewport SVG image
We were previously crashing by a division by zero due to an aspect ratio of zero on https://comicbookshop.co.nz/
This commit is contained in:
parent
be36dbce7d
commit
d48316ce15
Notes:
sideshowbarker
2024-07-17 02:23:25 +09:00
Author: https://github.com/shannonbooth
Commit: d48316ce15
Pull-request: https://github.com/SerenityOS/serenity/pull/24374
3 changed files with 23 additions and 2 deletions
|
@ -155,9 +155,16 @@ Optional<CSSPixelFraction> SVGDecodedImageData::intrinsic_aspect_ratio() const
|
|||
if (width.has_value() && height.has_value())
|
||||
return *width / *height;
|
||||
|
||||
if (auto const& viewbox = m_root_element->view_box(); viewbox.has_value())
|
||||
return CSSPixels::nearest_value_for(viewbox->width) / CSSPixels::nearest_value_for(viewbox->height);
|
||||
if (auto const& viewbox = m_root_element->view_box(); viewbox.has_value()) {
|
||||
auto viewbox_width = CSSPixels::nearest_value_for(viewbox->width);
|
||||
|
||||
if (viewbox_width == 0)
|
||||
return {};
|
||||
|
||||
auto viewbox_height = CSSPixels::nearest_value_for(viewbox->height);
|
||||
|
||||
return viewbox_width / viewbox_height;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue