[PATCH 04/10] shared: Don't leak file descriptor in shared/image-loader.c

Pekka Paalanen ppaalanen at gmail.com
Sun Jul 8 00:27:36 PDT 2012


On Sun,  8 Jul 2012 03:03:41 +0200
Martin Olsson <martin at minimum.se> wrote:

> ---
>  shared/image-loader.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/shared/image-loader.c b/shared/image-loader.c
> index a3218df..b47c1a7 100644
> --- a/shared/image-loader.c
> +++ b/shared/image-loader.c
> @@ -359,8 +359,10 @@ load_image(const char *filename)
>  	if (fp == NULL)
>  		return NULL;
>  
> -	if (fread(header, sizeof header, 1, fp) != 1)
> +	if (fread(header, sizeof header, 1, fp) != 1) {
> +		fclose(fp);
>  		return NULL;
> +	}
>  
>  	rewind(fp);
>  	for (i = 0; i < ARRAY_LENGTH(loaders); i++) {

Reviewed-by: Pekka Paalanen <ppaalanen at gmail.com>

Thanks,
pq


More information about the wayland-devel mailing list