Avoid crash in PlacementAmongFloats (#30235)

PlacementAmongFloats was assuming that there would always be a FloatBand
at a position smaller than or equal to the given ceiling, but this was
not the case for negative ceilings.

The reason is that the FloatContext initialized the FloatBandTree with
a band at 0, and another at +∞.

This patch changes the initial bands to −∞ and +∞. This seems more
consistent and matches the expectation of PlacementAmongFloats.
This commit is contained in:
Oriol Brufau 2023-08-29 20:40:05 +02:00 committed by GitHub
parent 70f0088986
commit 9aa3f74878
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 1 deletions

View file

@ -307,7 +307,7 @@ impl FloatContext {
pub fn new(max_inline_size: Length) -> Self {
let mut bands = FloatBandTree::new();
bands = bands.insert(FloatBand {
top: Length::zero(),
top: Length::new(-f32::INFINITY),
left: None,
right: None,
});