Re: [hackers] [sent][PATCH] free XImage before creating a new one

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Mon, 9 Jan 2023 18:26:25 +0100

On Mon, Jan 09, 2023 at 03:07:48PM +0000, Augusto Castelo wrote:
> ffprepare was allocating a new XImage but wasn't freeing the
> previously allocated one
> ---
> sent.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sent.c b/sent.c
> index 9534fca..d949d71 100644
> --- a/sent.c
> +++ b/sent.c
> _AT_@ -270,6 +270,9 @@ ffprepare(Image *img)
> if (depth < 24)
> die("sent: Display color depths < 24 not supported");
>
> + if (img->ximg)
> + XDestroyImage(img->ximg);
> +
> if (!(img->ximg = XCreateImage(xw.dpy, CopyFromParent, depth, ZPixmap, 0,
> NULL, width, height, 32, 0)))
> die("sent: Unable to create XImage");
> --
> 2.39.0
>

Applied, thank you.

The memory leak was easily reproducable by opening sent:

        sent < example

... and then resizing the nyancat window.

-- 
Kind regards,
Hiltjo
Received on Mon Jan 09 2023 - 18:26:25 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 09 2023 - 18:36:34 CET