mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Don't crash when SVG viewbox has a width of 0
Previously, `SVGSVGBox` would have a natural aspect ratio of 0 if it had a viewbox with zero width. This led to a division by zero, causing a crash. Found by Domato.
This commit is contained in:
parent
604f6040a1
commit
4cdafea363
Notes:
github-actions[bot]
2024-07-22 07:14:21 +00:00
Author: https://github.com/tcl3
Commit: 4cdafea363
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/758
3 changed files with 14 additions and 2 deletions
|
@ -75,9 +75,10 @@ Optional<CSSPixelFraction> SVGSVGBox::calculate_intrinsic_aspect_ratio() const
|
|||
auto const& viewbox = dom_node().view_box().value();
|
||||
|
||||
// 2. return viewbox.width / viewbox.height
|
||||
auto viewbox_width = CSSPixels::nearest_value_for(viewbox.width);
|
||||
auto viewbox_height = CSSPixels::nearest_value_for(viewbox.height);
|
||||
if (viewbox_height != 0)
|
||||
return CSSPixels::nearest_value_for(viewbox.width) / viewbox_height;
|
||||
if (viewbox_width != 0 && viewbox_height != 0)
|
||||
return viewbox_width / viewbox_height;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue