[vlc-commits] MP4: check string existence before EnsureUTF8
Jean-Baptiste Kempf
git at videolan.org
Mon Jul 4 14:27:52 CEST 2016
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jul 4 14:26:58 2016 +0200| [c60a18180689c175e7fafb82f0f9b11b53d98b30] | 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=c60a18180689c175e7fafb82f0f9b11b53d98b30
---
modules/demux/mp4/mp4.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 998196f..93d2c8d 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1797,14 +1797,19 @@ 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) 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 +1858,16 @@ 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(*(&p_buffer[2])==(char)255 && *(&p_buffer[2]+1)==(char)254){ // UTF-16 BOM
s->psz_name = FromCharset("UTF-16LE", &p_buffer[2], i_len);
} else { // non UTF-16 strings
s->psz_name = strndup( &p_buffer[2], i_len );
}
+ if( s->psz_name == NULL ) 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