mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
width() and height() computed `x1 - x0` / `y1 - y0` with plain i32 subtraction. For extreme edges (e.g. an inverted i32::MAX..i32::MIN rect, or a valid rect spanning most of the i32 range) the subtraction overflows: debug builds panic, release builds wrap. warp.* commands build a Rect straight from the JSON `rect` param, so an extreme value reached this from user input. Both now return the exact extent via `abs_diff` when the far edge is past the near one, and 0 otherwise. The extent of any i32 pair fits in u32, so no clamping or casting is needed. A plain `saturating_sub` would avoid the panic but turn a wide valid rect into a width of i32::MAX, which is wrong. Follow-up (not in this change): warp_cmds still accepts absurd `rect` params; it should reject them with a parameter error up front. Co-authored-by: Luna <[email protected]>