[vlc-commits] decoder: make sure we don't make any damage when changing the decoder_owner

Steve Lhomme git at videolan.org
Thu Sep 19 15:03:40 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Sep 19 09:30:01 2019 +0200| [c53606a05c19c63e07daac85af7650584ce259c6] | committer: Steve Lhomme

decoder: make sure we don't make any damage when changing the decoder_owner

The decoder_Destroy() can be called on the dec element of the owner because
it's the first element of the structure and the owner is actually the decoder
itself.

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

 src/input/decoder.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 03286f887c..57c9de6a1e 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1753,6 +1753,8 @@ static struct decoder_owner * CreateDecoder( vlc_object_t *p_parent,
 {
     decoder_t *p_dec;
     struct decoder_owner *p_owner;
+    static_assert(offsetof(struct decoder_owner, dec) == 0,
+                  "the decoder must be first in the owner structure");
 
     p_owner = vlc_custom_create( p_parent, sizeof( *p_owner ), "decoder" );
     if( p_owner == NULL )
@@ -1973,7 +1975,7 @@ static void DeleteDecoder( decoder_t * p_dec )
     vlc_mutex_destroy( &p_owner->lock );
     vlc_mutex_destroy( &p_owner->mouse_lock );
 
-    decoder_Destroy( p_dec );
+    decoder_Destroy( &p_owner->dec );
 }
 
 /* */



More information about the vlc-commits mailing list