[vlc-commits] decoder_helpers: fix clean order

Thomas Guillem git at videolan.org
Tue Feb 19 17:55:58 CET 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 19 13:23:22 2019 +0100| [e327b46e44978eed8972e7741c26f5de252f8f5e] | committer: Thomas Guillem

decoder_helpers: fix clean order

The module need to be unloaded before the dec struct is cleaned.

This fixes an undefined behavior with threaded decoders like avcodec when they
called decoder_UpdateVideoFormat()/dec_NewPicture() from an other thread just
before they were unloaded.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e327b46e44978eed8972e7741c26f5de252f8f5e
---

 src/input/decoder_helpers.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 3cc02de8d6..b0a7c1890a 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -48,6 +48,12 @@ void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
 
 void decoder_Clean( decoder_t *p_dec )
 {
+    if ( p_dec->p_module != NULL )
+    {
+        module_unneed(p_dec, p_dec->p_module);
+        p_dec->p_module = NULL;
+    }
+
     es_format_Clean( &p_dec->fmt_in );
     es_format_Clean( &p_dec->fmt_out );
 
@@ -56,11 +62,6 @@ void decoder_Clean( decoder_t *p_dec )
         vlc_meta_Delete(p_dec->p_description);
         p_dec->p_description = NULL;
     }
-    if ( p_dec->p_module != NULL )
-    {
-        module_unneed(p_dec, p_dec->p_module);
-        p_dec->p_module = NULL;
-    }
 }
 
 void decoder_Destroy( decoder_t *p_dec )



More information about the vlc-commits mailing list