From 5e7c34f5b3e67fb5cd380be70e02d9e73651a686 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 15 Oct 2022 20:18:25 +0100 Subject: [PATCH] lcd: Fix off by one error in clipping check When I converted all the clipping checks in 4b8fe8acd1c0 I messed up the hline and vline checks. This produced some weird panics on the Shanling Q1, probably memory corruption -- but somehow it got past AddressSanitizer. Go figure. Change-Id: I84820c23a491d422218c72d2d5e199e2fc7def0f --- firmware/drivers/lcd-bitmap-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index bb98ceed8a..4a94aff412 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -77,7 +77,7 @@ static inline bool clip_viewport_pixel(struct viewport *vp, int *x, int *y) static inline bool clip_viewport_hline(struct viewport *vp, int *x1, int *x2, int *y) { - if (*y < 0 || *y > vp->height) + if (*y < 0 || *y >= vp->height) return false; if (*x2 < *x1) { @@ -105,7 +105,7 @@ static inline bool clip_viewport_hline(struct viewport *vp, static inline bool clip_viewport_vline(struct viewport *vp, int *x, int *y1, int *y2) { - if (*x < 0 || *x > vp->width) + if (*x < 0 || *x >= vp->width) return false; if (*y2 < *y1) {