[vlc-devel] [PATCH 18/18] modules:decoders: clean the es_format_t before overwriting it

Steve Lhomme robux4 at videolabs.io
Mon Jul 17 16:33:24 CEST 2017


For transcoders the fmt_out can be filled with dynamically allocated data.
---
 modules/codec/ddummy.c   | 1 +
 modules/codec/rawvideo.c | 3 +++
 modules/codec/xwd.c      | 1 +
 3 files changed, 5 insertions(+)

diff --git a/modules/codec/ddummy.c b/modules/codec/ddummy.c
index 266e636b49..e38dd5fd86 100644
--- a/modules/codec/ddummy.c
+++ b/modules/codec/ddummy.c
@@ -111,6 +111,7 @@ static int OpenDecoderCommon( vlc_object_t *p_this, bool b_force_dump )
     /* Set callbacks */
     p_dec->pf_decode = DecodeBlock;
 
+    es_format_Clean( &p_dec->fmt_out );
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
 
     return VLC_SUCCESS;
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index 3db4c94d0b..19732ad160 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -101,7 +101,10 @@ static int OpenCommon( decoder_t *p_dec, bool b_packetizer )
         p_dec->fmt_in.video.i_visible_height = p_dec->fmt_in.video.i_height;
 
     if ( !b_packetizer )
+    {
+        es_format_Clean( &p_dec->fmt_out );
         es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
+    }
 
     date_Init( &p_sys->pts, p_dec->fmt_out.video.i_frame_rate,
                p_dec->fmt_out.video.i_frame_rate_base );
diff --git a/modules/codec/xwd.c b/modules/codec/xwd.c
index 3e26b0be9f..79423602fd 100644
--- a/modules/codec/xwd.c
+++ b/modules/codec/xwd.c
@@ -50,6 +50,7 @@ static int Open(vlc_object_t *obj)
         return VLC_EGENERIC;
 
     dec->pf_decode = Decode;
+    es_format_Clean(&dec->fmt_out);
     es_format_Copy(&dec->fmt_out, &dec->fmt_in);
     dec->fmt_out.i_codec = VLC_CODEC_RGB32;
     return VLC_SUCCESS;
-- 
2.12.1



More information about the vlc-devel mailing list