[vlc-devel] [PATCH] Fix double free in stream deletion

chishtiawais511 at gmail.com chishtiawais511 at gmail.com
Tue Mar 19 21:59:04 CET 2019


From: Awais Chishti <chishtiawais511 at gmail.com>

The function Del() in modules/stream_out/transcode/transcode.c is calling module_unneed() once in the transcode_*_clean() functions and then again in the last DeleteSoutStreamID() call after which VLC crashes. It seems that a workaround is implemented in only transcode_audio_clean(), which the patch repeats for the remaining transcode_*_clean() functions.
---
 modules/stream_out/transcode/spu.c   | 4 ++++
 modules/stream_out/transcode/video.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/modules/stream_out/transcode/spu.c b/modules/stream_out/transcode/spu.c
index b491774241..d201af99f1 100644
--- a/modules/stream_out/transcode/spu.c
+++ b/modules/stream_out/transcode/spu.c
@@ -159,11 +159,15 @@ int transcode_spu_init( sout_stream_t *p_stream, const es_format_t *p_fmt,
 void transcode_spu_clean( sout_stream_t *p_stream, sout_stream_id_sys_t *id)
 {
     VLC_UNUSED(p_stream);
+
     /* Close decoder */
     if( id->p_decoder->p_module )
         module_unneed( id->p_decoder, id->p_decoder->p_module );
+    id->p_decoder->p_module = NULL;
+
     if( id->p_decoder->p_description )
         vlc_meta_Delete( id->p_decoder->p_description );
+    id->p_decoder->p_description = NULL;
 
     /* Close encoder */
     if( id->encoder )
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 24556e1b2d..7ebc9436d8 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -313,8 +313,11 @@ void transcode_video_clean( sout_stream_t *p_stream,
     /* Close decoder */
     if( id->p_decoder->p_module )
         module_unneed( id->p_decoder, id->p_decoder->p_module );
+    id->p_decoder->p_module = NULL;
+
     if( id->p_decoder->p_description )
         vlc_meta_Delete( id->p_decoder->p_description );
+    id->p_decoder->p_description = NULL;
 
     /* Close encoder */
     transcode_encoder_close( id->encoder );
-- 
2.21.0



More information about the vlc-devel mailing list