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

Romain Vimont rom1v at videolabs.io
Thu Dec 12 19:18:29 CET 2019

From: Romain Vimont <rom at rom1v.com>

In case p_surface is NULL, vlc_video_context_Release() was called

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.
 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;

More information about the vlc-devel mailing list