[Piglit] [PATCH] texwrap: Fix memory leaks.

Brian Paul brianp at vmware.com
Mon Dec 5 07:13:48 PST 2011


On 12/03/2011 11:01 PM, Vinson Lee wrote:
> Fixes Coverity resource leak defect.
>
> Signed-off-by: Vinson Lee<vlee at vmware.com>
> ---
>   tests/texturing/texwrap.c |   15 ++++++++++++---
>   1 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/tests/texturing/texwrap.c b/tests/texturing/texwrap.c
> index dae088a..7e82469 100644
> --- a/tests/texturing/texwrap.c
> +++ b/tests/texturing/texwrap.c
> @@ -1211,9 +1211,14 @@ static void init_textures()
>           switch (texture_format->internalformat) {
>           case GL_DEPTH24_STENCIL8:
>               /* Convert to D24X8_UNORM. */
> -            {
> -                uint32_t *p = (uint32_t*)
> -                              (data = malloc(SIZEMAX * SIZEMAX * SIZEMAX * 4));
> +           {
> +                uint32_t *p;
> +
> +                if (data != no_border_image) {
> +                    free(data);
> +                }
> +
> +                p = (uint32_t*)(data = malloc(SIZEMAX * SIZEMAX * SIZEMAX * 4));
>
>                   for (x = 0; x<  size_z*size_y*size_x; x++) {
>                       p[x] = (uint32_t)(no_border_image[x] * ((1<<24) - 1))<<  8;
> @@ -1221,6 +1226,10 @@ static void init_textures()
>               }
>               break;
>           case GL_DEPTH32F_STENCIL8:
> +            if (data != no_border_image) {
> +                free(data);
> +            }
> +
>               /* Convert to D32F_X24X8. */
>               data = malloc(SIZEMAX * SIZEMAX * SIZEMAX * 8);
>

I don't think we have to be too concerned about memory leaks in piglit 
tests but this looks OK.

The next three patches also look OK.

Reviewed-by: Brian Paul <brianp at vmware.com>

-Brian


More information about the Piglit mailing list