Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
99df59ea by Steve Lhomme at 2026-01-09T13:04:54+00:00
demux: mkv: split helpers to get UTF8 without a copy

- - - - -
693f19ed by Steve Lhomme at 2026-01-09T13:04:54+00:00
demux: mkv: don't keep the segment string date

The value is only turned into a string for logging.
If we want to keep the date we just use the integer value.

- - - - -
39cde597 by Steve Lhomme at 2026-01-09T13:04:54+00:00
demux: mkv: don't keep the segment original file name

It's not used and not reliable.

- - - - -
36d591a3 by Steve Lhomme at 2026-01-09T13:04:54+00:00
demux: mkv: fix leak on multiple string definition

These elements are all supposed to be unique. But as we always kept the last
value, we continue to do so without leaking the previous value.

Fixes #29521

- - - - -


3 changed files:

- modules/demux/mkv/matroska_segment.cpp
- modules/demux/mkv/matroska_segment.hpp
- modules/demux/mkv/matroska_segment_parse.cpp


Changes:

=====================================
modules/demux/mkv/matroska_segment.cpp
=====================================
@@ -56,9 +56,7 @@ matroska_segment_c::matroska_segment_c( demux_sys_t & 
demuxer, matroska_iostream
     ,b_cues(false)
     ,psz_muxing_application(NULL)
     ,psz_writing_application(NULL)
-    ,psz_segment_filename(NULL)
     ,psz_title(NULL)
-    ,psz_date_utc(NULL)
     ,i_default_edition(0)
     ,sys(demuxer)
     ,ep( EbmlParser(&estream, p_seg, &demuxer.demuxer ))
@@ -71,9 +69,7 @@ matroska_segment_c::~matroska_segment_c()
 {
     free( psz_writing_application );
     free( psz_muxing_application );
-    free( psz_segment_filename );
     free( psz_title );
-    free( psz_date_utc );
 
     delete segment;
     delete p_segment_uid;


=====================================
modules/demux/mkv/matroska_segment.hpp
=====================================
@@ -122,9 +122,7 @@ public:
     /* info */
     char                    *psz_muxing_application;
     char                    *psz_writing_application;
-    char                    *psz_segment_filename;
     char                    *psz_title;
-    char                    *psz_date_utc;
 
     /* !!!!! GCC 3.3 bug on Darwin !!!!! */
     /* when you remove this variable the compiler issues an atomicity error */


=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -80,9 +80,14 @@ static inline void fill_extra_data( mkv_track_t *p_tk, 
unsigned int offset )
 /*****************************************************************************
  * Some functions to manipulate memory
  *****************************************************************************/
+static inline const char * ToUTF8Const( const UTFstring &u )
+{
+    return u.GetUTF8().c_str();
+}
+
 static inline char * ToUTF8( const UTFstring &u )
 {
-    return strdup( u.GetUTF8().c_str() );
+    return strdup( ToUTF8Const(u) );
 }
 
 /*****************************************************************************
@@ -356,6 +361,7 @@ void matroska_segment_c::ParseTrackEntry( const 
KaxTrackEntry *m )
         }
         E_CASE( KaxTrackName, tname )
         {
+            free(vars.tk->fmt.psz_description);
             vars.tk->fmt.psz_description = ToUTF8( UTFstring( tname ) );
             debug( vars, "Track Name=%s", vars.tk->fmt.psz_description ? 
vars.tk->fmt.psz_description : "(null)" );
         }
@@ -1225,21 +1231,23 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
         }
         E_CASE( KaxMuxingApp, mapp )
         {
+            free(vars.obj->psz_muxing_application);
             vars.obj->psz_muxing_application = ToUTF8( UTFstring( mapp ) );
             debug( vars, "Muxing Application=%s", 
vars.obj->psz_muxing_application );
         }
         E_CASE( KaxWritingApp, wapp )
         {
+            free(vars.obj->psz_writing_application);
             vars.obj->psz_writing_application = ToUTF8( UTFstring( wapp ) );
             debug( vars, "Writing Application=%s", 
vars.obj->psz_writing_application );
         }
         E_CASE( KaxSegmentFilename, sfn )
         {
-            vars.obj->psz_segment_filename = ToUTF8( UTFstring( sfn ) );
-            debug( vars, "Segment Filename=%s", vars.obj->psz_segment_filename 
);
+            debug( vars, "Segment Filename=%s", ToUTF8Const( UTFstring( sfn ) 
) );
         }
         E_CASE( KaxTitle, title )
         {
+            free(vars.obj->psz_title);
             vars.obj->psz_title = ToUTF8( UTFstring( title ) );
             debug( vars, "Title=%s", vars.obj->psz_title );
         }
@@ -1258,8 +1266,7 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
                 strftime( buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y",
                           &tmres ) )
             {
-                vars.obj->psz_date_utc = strdup( buffer );
-                debug( vars, "Date=%s", vars.obj->psz_date_utc );
+                debug( vars, "Date=%s", buffer );
             }
         }
         E_CASE( KaxChapterTranslate, trans )



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/7d6b04dd6dd5e46d4156044b6586e7a6527bddc0...36d591a3e93dbf99e1d23a3c06e8ace98995e83e

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/7d6b04dd6dd5e46d4156044b6586e7a6527bddc0...36d591a3e93dbf99e1d23a3c06e8ace98995e83e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to