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

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 19 09:31:42 CEST 2019


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.
---
 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 2935e3d6ef7..3e550152b15 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1758,6 +1758,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 )
@@ -1978,7 +1980,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 );
 }
 
 /* */
-- 
2.17.1



More information about the vlc-devel mailing list