[vlc-commits] demux: ts: proper init/clean for fmt in hotfixes

Francois Cartegnie git at videolan.org
Tue Jul 25 14:07:31 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 24 18:42:20 2017 +0200| [fb415ec996d9f1e3f419c2146fe8d1e5b53dcd09] | committer: Francois Cartegnie

demux: ts: proper init/clean for fmt in hotfixes

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

 modules/demux/mpeg/ts_hotfixes.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mpeg/ts_hotfixes.c b/modules/demux/mpeg/ts_hotfixes.c
index f26425bd6c..03b61c08dd 100644
--- a/modules/demux/mpeg/ts_hotfixes.c
+++ b/modules/demux/mpeg/ts_hotfixes.c
@@ -303,8 +303,9 @@ void MissingPATPMTFixup( demux_t *p_demux )
     {
         pesmux_stream_t pes;
         tsmux_stream_t ts;
+        es_format_t fmt;
     };
-    es_format_t esfmt = {0};
+
     struct esstreams_t *esstreams = calloc( i_num_pes, sizeof(struct esstreams_t) );
     pes_mapped_stream_t *mapped = calloc( i_num_pes, sizeof(pes_mapped_stream_t) );
     if( esstreams && mapped )
@@ -318,10 +319,14 @@ void MissingPATPMTFixup( demux_t *p_demux )
                 p_pid->probed.i_fourcc == 0 )
                 continue;
 
-            esfmt.i_codec = p_pid->probed.i_fourcc;
+            es_format_Init(&esstreams[j].fmt, p_pid->probed.i_cat, p_pid->probed.i_fourcc);
+
             if( VLC_SUCCESS !=
-                FillPMTESParams(mux_standard, &esfmt, &esstreams[j].ts, &esstreams[j].pes ) )
+                FillPMTESParams(mux_standard, &esstreams[j].fmt, &esstreams[j].ts, &esstreams[j].pes ) )
+            {
+                es_format_Clean( &esstreams[j].fmt );
                 continue;
+            }
 
             /* Important for correct remapping: Enforce probed PES stream id */
             esstreams[j].pes.i_stream_id = p_pid->probed.i_stream_id;
@@ -329,7 +334,7 @@ void MissingPATPMTFixup( demux_t *p_demux )
             esstreams[j].ts.i_pid = p_pid->i_pid;
             mapped[j].pes = &esstreams[j].pes;
             mapped[j].ts = &esstreams[j].ts;
-            mapped[j].fmt = &esfmt;
+            mapped[j].fmt = &esstreams[j].fmt;
             j++;
         }
 
@@ -341,6 +346,10 @@ void MissingPATPMTFixup( demux_t *p_demux )
                 NULL,
                 1, &pmtprogramstream, &i_program_number,
                 j, mapped );
+
+        /* Cleanup */
+        for( int i=0; i<j; i++ )
+            es_format_Clean( &esstreams[i].fmt );
     }
     free(esstreams);
     free(mapped);



More information about the vlc-commits mailing list