[Piglit] [PATCH v2] arb_direct_state_access: Fix memory leak.

Brian Paul brianp at vmware.com
Sat Jan 10 06:43:00 PST 2015


On 01/09/2015 06:45 PM, Vinson Lee wrote:
> Fix resource leak defect reported by Coverity.
>
> Also move piglit_rgbw_image_ubyte call outside of loop as suggested by
> Brian Paul.
>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>   tests/spec/arb_direct_state_access/getcompressedtextureimage.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
> index 734ef72..9546af5 100644
> --- a/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
> +++ b/tests/spec/arb_direct_state_access/getcompressedtextureimage.c
> @@ -96,13 +96,15 @@ make_layer_data(int num_layers)
>   	int z;
>   	GLubyte *layer_data =
>   		malloc(num_layers * IMAGE_SIZE * sizeof(GLubyte));
> +	GLubyte *data = piglit_rgbw_image_ubyte(IMAGE_WIDTH,
> +						IMAGE_HEIGHT, true);
>
>   	for (z = 0; z < num_layers; z++) {
> -		GLubyte *data = piglit_rgbw_image_ubyte(IMAGE_WIDTH,
> -							IMAGE_HEIGHT, true);
>   		memcpy(layer_data + IMAGE_SIZE * z, data, IMAGE_SIZE);
>   	}
>
> +	free(data);
> +
>   	/* Show the first layer of the completed layer data. */
>   	show_image(layer_data, num_layers, "Test Data");
>
>

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



More information about the Piglit mailing list