[PATCH 1/5] graphic_utils: Clip to screen boundaries
Sascha Hauer
s.hauer at pengutronix.de
Wed Sep 25 07:34:49 PDT 2024
Do not render the parts of the image that are outside the screen
boundaries to prevent memory corruptions.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
lib/gui/graphic_utils.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index d91a7f3550..93ef1214f9 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -229,6 +229,9 @@ void gu_rgba_blend(struct fb_info *info, struct image *img, void* buf, int heigh
line_length = info->line_length;
for (y = 0; y < height; y++) {
+ if (y + starty >= info->yres)
+ break;
+
adr = buf + (y + starty) * line_length +
startx * (info->bits_per_pixel >> 3);
image = img->data + (y * img->width *img_byte_per_pixel);
@@ -236,6 +239,9 @@ void gu_rgba_blend(struct fb_info *info, struct image *img, void* buf, int heigh
for (x = 0; x < width; x++) {
uint8_t *pixel = image;
+ if (x + startx >= info->xres)
+ break;
+
if (is_rgba)
gu_set_rgba_pixel(info, adr, pixel[0], pixel[1],
pixel[2], pixel[3]);
--
2.39.5
More information about the barebox
mailing list