libcamera: software_isp: Fix width adjustment in SwStatsCpu::setWindow

SwStatsCpu::setWindow reduces the window width by the added x-offset, to
prevent exceeding image bounds.  But if the window width is smaller than
the x-offset, we get unsigned integer underflow.  Fix it by setting the
window width to 0 in such a case.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Tested-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Milan Zamazal
2025-09-29 22:19:18 +02:00
committed by Kieran Bingham
parent 48b3b7bacf
commit e79cec02fb

View File

@@ -438,7 +438,7 @@ void SwStatsCpu::setWindow(const Rectangle &window)
window_.y &= ~(patternSize_.height - 1);
/* width_ - xShift_ to make sure the window fits */
window_.width -= xShift_;
window_.width = (window_.width > xShift_ ? window_.width - xShift_ : 0);
window_.width &= ~(patternSize_.width - 1);
window_.height &= ~(patternSize_.height - 1);
}