From 13ab9c1adc8189bf4a74801efe57311b2a591caa Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 21 Sep 2025 13:41:23 +0100 Subject: [PATCH] Fix 6e90b828c6: Off-by-one in Rect::CentreTo. (#14643) * Rect right/bottom are inclusive so -1 must be taken from width/height. * Misnamed variable, `new_right` is actually `new_top`. --- src/core/geometry_type.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/geometry_type.hpp b/src/core/geometry_type.hpp index b3400c2cc3..f5bb66f554 100644 --- a/src/core/geometry_type.hpp +++ b/src/core/geometry_type.hpp @@ -261,8 +261,8 @@ struct Rect { [[nodiscard]] inline Rect CentreTo(int width, int height) const { int new_left = CentreBounds(this->left, this->right, width); - int new_right = CentreBounds(this->top, this->bottom, height); - return {new_left, new_right, new_left + width, new_right + height}; + int new_top = CentreBounds(this->top, this->bottom, height); + return {new_left, new_top, new_left + width - 1, new_top + height - 1}; } };