[Piglit] [PATCH] cl-api-enqueue-fill-image: Fix memory leaks.

Serge Martin edb+piglit at sigluy.net
Sun Nov 22 01:45:33 PST 2015


I think we can

free(image_support):
image_suppot = NULL;

 right after the test

	if (!*image_support) {
		fprintf(stderr, "No image support\n");
		free(image_support);
		return PIGLIT_SKIP;
	}

that would avoid the need to add it in every PIGLIT_FAIL return;

Serge

On Monday 16 November 2015 23:48:14 Vinson Lee wrote:
> Fixes Coverity "resource leak" defects.
> 
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/cl/api/enqueue-fill-image.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/cl/api/enqueue-fill-image.c
> b/tests/cl/api/enqueue-fill-image.c index ebcfba4..994ccb4 100644
> --- a/tests/cl/api/enqueue-fill-image.c
> +++ b/tests/cl/api/enqueue-fill-image.c
> @@ -129,12 +129,14 @@ piglit_cl_test(const int argc,
>  	if(!piglit_cl_check_error(err, CL_SUCCESS)) {
>  		fprintf(stderr, "Failed (error code: %s): Creating an image\n",
>  		        piglit_cl_get_error_name(err));
> +		free(image_support);
>  		return PIGLIT_FAIL;
>  	}
> 
>  	if (!test(queue, image, pattern, origin, region,
>  	          0, NULL, NULL,
>  	          CL_SUCCESS, &result, "Enqueuing the image to be filled")) {
> +		free(image_support);
>  		return PIGLIT_FAIL;
>  	}
> 
> @@ -145,6 +147,7 @@ piglit_cl_test(const int argc,
>  	if(!piglit_cl_check_error(err, CL_SUCCESS)) {
>  		fprintf(stderr, "Failed (error code: %s): Reading image\n",
>  		        piglit_cl_get_error_name(err));
> +		free(image_support);
>  		return PIGLIT_FAIL;
>  	}
> 
> @@ -169,6 +172,7 @@ piglit_cl_test(const int argc,
>  		if (!piglit_cl_probe_integer(dst_buf[i], exp_buf[i], 0)) {
>  			fprintf(stderr, "Error at %d: got %d, expected %d\n",
>  			        i, dst_buf[i], exp_buf[i]);
> +			free(image_support);
>  			return PIGLIT_FAIL;
>  		}
>  	}



More information about the Piglit mailing list