[PATCH weston] wcap: Prevent fd leak in wcap_decoder_create() fail path

Quentin Glidic sardemff7+wayland at sardemff7.net
Thu Mar 30 23:42:11 UTC 2017


On 3/29/17 10:41 PM, Sergi Granell wrote:
> Signed-off-by: Sergi Granell <xerpi.g.12 at gmail.com>

Well, good: ;-)
Reviewed-by: Quentin Glidic <sardemff7+git at sardemff7.net>

And pushed:
fec723ef..597dde5c  master -> master

Thanks,


> ---
>   wcap/wcap-decode.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/wcap/wcap-decode.c b/wcap/wcap-decode.c
> index e3b8985f..7e8c8477 100644
> --- a/wcap/wcap-decode.c
> +++ b/wcap/wcap-decode.c
> @@ -131,6 +131,7 @@ wcap_decoder_create(const char *filename)
>   			    PROT_READ, MAP_PRIVATE, decoder->fd, 0);
>   	if (decoder->map == MAP_FAILED) {
>   		fprintf(stderr, "mmap failed\n");
> +		close(decoder->fd);
>   		free(decoder);
>   		return NULL;
>   	}
> @@ -146,6 +147,7 @@ wcap_decoder_create(const char *filename)
>   	frame_size = header->width * header->height * 4;
>   	decoder->frame = malloc(frame_size);
>   	if (decoder->frame == NULL) {
> +		close(decoder->fd);
>   		free(decoder);
>   		return NULL;
>   	}
> 


-- 

Quentin “Sardem FF7” Glidic


More information about the wayland-devel mailing list