[vlc-devel] [PATCH] mediacodec: fix cleanup on error

Steve Lhomme robux4 at ycbcr.xyz
Fri Dec 13 09:54:36 CET 2019


On 2019-12-12 19:18, Romain Vimont wrote:
> From: Romain Vimont <rom at rom1v.com>
> 
> In case p_surface is NULL, vlc_video_context_Release() was called
> immediately.
> 
> This caused 2 problems:
>   - it indirectly uses avctx->dec_opaque, which is not initialized yet;
>   - it indirectly calls CleanDecoder a first time, before it is called
>     again after "goto bailout;".
> 
> To fix the problem, let the cleanup in "bailout" do its job.

In this case you're leaking the video.ctx which is only released in 
CloseDecoder(), which is not called when the decoder did not open.

To avoid this issue, I think the video.ctx should be the last thing 
allocated in this function.

> ---
>   modules/codec/omxil/mediacodec.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
> index 2f99ea93a2..41b6edd5ab 100644
> --- a/modules/codec/omxil/mediacodec.c
> +++ b/modules/codec/omxil/mediacodec.c
> @@ -675,8 +675,6 @@ CreateVideoContext(decoder_t *p_dec)
>       if (!p_sys->video.p_surface)
>       {
>           msg_Err(p_dec, "Could not find a valid ANativeWindow");
> -        vlc_video_context_Release(p_sys->video.ctx);
> -        p_sys->video.ctx = NULL;
>           return VLC_EGENERIC;
>       }
>   
> -- 
> 2.24.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list