[vlc-commits] MP4: check string existence before EnsureUTF8

Jean-Baptiste Kempf git at videolan.org
Mon Jul 4 14:47:29 CEST 2016


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jul  4 14:26:58 2016 +0200| [5614d59669193e12244299f51d92651ab9b080e6] | committer: Jean-Baptiste Kempf

MP4: check string existence before EnsureUTF8

And other allocation checks

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

 modules/demux/mp4/mp4.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index ae82df4..4fb7f7c 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1797,14 +1797,23 @@ static void Close ( vlc_object_t * p_this )
 static void LoadChapterGpac( demux_t  *p_demux, MP4_Box_t *p_chpl )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    int i;
+
+    if( BOXDATA(p_chpl)->i_chapter == 0 )
+        return;
 
     p_sys->p_title = vlc_input_title_New();
-    for( i = 0; i < BOXDATA(p_chpl)->i_chapter; i++ )
+    for( int i = 0; i < BOXDATA(p_chpl)->i_chapter && p_sys->p_title; i++ )
     {
         seekpoint_t *s = vlc_seekpoint_New();
+        if( s == NULL) continue;
 
         s->psz_name = strdup( BOXDATA(p_chpl)->chapter[i].psz_name );
+        if( s->psz_name == NULL)
+        {
+            vlc_seekpoint_Delete( s );;
+            continue;
+        }
+
         EnsureUTF8( s->psz_name );
         s->i_time_offset = BOXDATA(p_chpl)->chapter[i].i_start / 10;
         TAB_APPEND( p_sys->p_title->i_seekpoint, p_sys->p_title->seekpoint, s );
@@ -1853,15 +1862,20 @@ static void LoadChapterApple( demux_t  *p_demux, mp4_track_t *tk )
             if( i_len > 0 )
             {
                 seekpoint_t *s = vlc_seekpoint_New();
+                if( s == NULL ) continue;
 
                 if( !memcmp( &p_buffer[2], "\xFF\xFE", 2 ) )
                     s->psz_name = FromCharset("UTF-16LE", &p_buffer[2], i_len);
                 else
                     s->psz_name = strndup( &p_buffer[2], i_len );
+
+                if( s->psz_name == NULL )
+                {
+                    vlc_seekpoint_Delete( s );
+                    continue;
                 }
 
                 EnsureUTF8( s->psz_name );
-
                 s->i_time_offset = i_dts + __MAX( i_pts_delta, 0 );
 
                 if( !p_sys->p_title )



More information about the vlc-commits mailing list