Re: [PATCH] dcc: free glz buffer after zlib compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 22, 2015 at 07:26:42PM +0000, Frediano Ziglio wrote:
> For zlib+glz compression image if first compressed with glz then the
> resulting buffer is compressed again with zlib then the buffer from
> zlib is returned to the caller.
> However the temporary glz buffer was not freed resulting in a memory
> leak.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/dcc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/server/dcc.c b/server/dcc.c
> index 7c16fc0..1a6a865 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -662,6 +662,9 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
>      int glz_size;
>      int zlib_size;
>  
> +    spice_assert(glz_data->data.bufs_tail == NULL);
> +    spice_assert(glz_data->data.bufs_head == NULL);
> +

I don't think this belongs to this patch, and this should be a
g_warn_if_fail() rather than an assertion. zlib_data would deserve the
same checks.

>      glz_data->data.bufs_tail = compress_buf_new();
>      glz_data->data.bufs_head = glz_data->data.bufs_tail;
>      glz_data->data.dcc = dcc;
> @@ -708,6 +711,13 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
>              compress_buf_free(buf);
>          }
>          goto glz;
> +    } else {
> +        while (glz_data->data.bufs_head) {
> +            RedCompressBuf *buf = glz_data->data.bufs_head;
> +            glz_data->data.bufs_head = buf->send_next;
> +            compress_buf_free(buf);
> +        }

This is repeated several times, imo this deserves to be moved to a
red_encoder_data_free() helper.

> +        glz_data->data.bufs_head = glz_data->data.bufs_tail = NULL;

glz_data->data.bufs_head should be NULL when we get here.



>      }
>  
>      dest->descriptor.type = SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB;
> @@ -725,6 +735,7 @@ glz:
>  
>      o_comp_data->comp_buf = glz_data->data.bufs_head;
>      o_comp_data->comp_buf_size = glz_size;
> +    glz_data->data.bufs_head = glz_data->data.bufs_tail = NULL;

This seems unrelated to the patch?

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]