[PATCH 1/5] graphic_utils: Clip to screen boundaries
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Sep 25 22:26:39 PDT 2024
On 25.09.24 16:34, Sascha Hauer wrote:
> 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>
Reviewed-by: Ahmad Fatoum <a.fatoum 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]);
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list