1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:37:44 +00:00

LibWeb: Use .to_px_or_zero() in tentative_height_for_replaced_element()

If just .to_px() is used the height can end up as the float `inf` or
`nan`. This caused an OOM when loading Polygon as this `inf` would
become a `nan` and propagate to the SVG painting, which then attempts
to draw a path with nan control points, which would make the
Gfx::Painter infinitely split the path till it OOM'd.
This commit is contained in:
MacDue 2023-05-11 22:14:31 +01:00 committed by Andreas Kling
parent eb76329ad8
commit 1012947a30

View file

@ -495,7 +495,8 @@ CSSPixels FormattingContext::tentative_height_for_replaced_element(LayoutState c
if (computed_height.is_auto()) if (computed_height.is_auto())
return 150; return 150;
return computed_height.to_px(box, available_space.height.to_px()); // FIXME: Handle cases when available_space is not definite.
return computed_height.to_px(box, available_space.height.to_px_or_zero());
} }
CSSPixels FormattingContext::compute_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box, AvailableSpace const& available_space) CSSPixels FormattingContext::compute_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box, AvailableSpace const& available_space)