mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	"open list:BAREBOX" <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/5] graphic_utils: Clip to screen boundaries
Date: Thu, 26 Sep 2024 07:26:39 +0200	[thread overview]
Message-ID: <239d4bc5-4cd0-48b7-8907-24dff31c9362@pengutronix.de> (raw)
In-Reply-To: <20240925-graphics-v1-1-f1fe5d2cceec@pengutronix.de>

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@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@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 |



  reply	other threads:[~2024-09-26  5:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:34 [PATCH 0/5] graphics updates Sascha Hauer
2024-09-25 14:34 ` [PATCH 1/5] graphic_utils: Clip to screen boundaries Sascha Hauer
2024-09-26  5:26   ` Ahmad Fatoum [this message]
2024-09-25 14:34 ` [PATCH 2/5] commands: splash: honour line_length Sascha Hauer
2024-09-26  5:31   ` Ahmad Fatoum
2024-09-26  6:48     ` Sascha Hauer
2024-09-25 14:34 ` [PATCH 3/5] gui: fix alpha blend Sascha Hauer
2024-09-26  5:33   ` Ahmad Fatoum
2024-09-25 14:34 ` [PATCH 4/5] fbconsole: make background pixels transparent Sascha Hauer
2024-09-26  5:38   ` Ahmad Fatoum
2024-09-26  7:02     ` Sascha Hauer
2024-09-25 14:34 ` [PATCH 5/5] fbconsole: actually store rows/cols Sascha Hauer
2024-09-26  5:39   ` Ahmad Fatoum
2024-09-27 10:38 ` [PATCH 0/5] graphics updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=239d4bc5-4cd0-48b7-8907-24dff31c9362@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox