[Mesa-dev] [PATCH] Fix generate_mipmap_compressed memory leaks.

Brian Paul brianp at vmware.com
Fri Jul 26 08:47:47 PDT 2013


On 07/25/2013 11:30 PM, Vinson Lee wrote:
> Fixes "Resource leak" defects reported by Coverity.
>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>   src/mesa/main/mipmap.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
> index 5839632..0ef6536 100644
> --- a/src/mesa/main/mipmap.c
> +++ b/src/mesa/main/mipmap.c
> @@ -2128,6 +2128,8 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
>         if (!dstImage) {
>            _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
>            free(temp_dst);
> +         free(temp_src_slices);
> +         free(temp_dst_slices);
>            return;
>         }
>
> @@ -2154,6 +2156,8 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
>                                         border, srcImage->InternalFormat,
>                                         srcImage->TexFormat)) {
>            free(temp_dst);
> +         free(temp_src_slices);
> +         free(temp_dst_slices);
>            return;
>         }

Hi Vinson,

Thanks for cleaning up after me.  I used valgrind to check for memory 
leaks when I made those changes, but of course, that doesn't usually 
catch the error paths.

I think we can do this cleanup a little cleaner with a "goto end".  I'll 
post a patch for that.  Could you then retest it with Coverity?

-Brian



More information about the mesa-dev mailing list