servo/components/layout_2020/table
Oriol Brufau f593b6d426
Protect create_spanned_slot_based_on_cell_above() against arithmetic underflow (#35437)
`Table::create_spanned_slot_based_on_cell_above()` was performing the
subtraction `self.slots.len() - 2`, which could theoretically result
in underflow if `self.slots.len()` is 0 or 1.

That shouldn't have been possible in practice, but it may be worth
addressing, to improve code robustness. So this patch:
  - Switches to `self.current_y()?.checked_sub(1)?`, which is safe and
    is easier to understand.
  - Moves `create_spanned_slot_based_on_cell_above()` to `TableBuilder`,
    since `current_y()` is there, and the method is only used when
    building the table anyways.
  - Ensures that both callers use `expect()` to assert that the method
    returned a value.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-02-12 20:11:11 +00:00
..
construct.rs Protect create_spanned_slot_based_on_cell_above() against arithmetic underflow (#35437) 2025-02-12 20:11:11 +00:00
layout.rs layout: Simplify Table::compute_inline_content_sizes (#35290) 2025-02-05 17:31:58 +00:00
mod.rs layout: Take percentage columns into account when sizing table grid min and max (#35167) 2025-01-27 15:04:37 +00:00