summaryrefslogtreecommitdiffstats
path: root/firmware/drivers
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-10-15 20:18:25 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-15 20:56:11 +0100
commit5e7c34f5b3e67fb5cd380be70e02d9e73651a686 (patch)
tree766ba8cb0f03ea51cd46cb3dab484737bfd68269 /firmware/drivers
parentffdc64bea210836e6e08352a81c049f4b969ce88 (diff)
downloadrockbox-5e7c34f5b3e67fb5cd380be70e02d9e73651a686.tar.gz
rockbox-5e7c34f5b3e67fb5cd380be70e02d9e73651a686.zip
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
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c4
1 files 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) {