[vlc-commits] demux: libasf: strings conversion can fail

Francois Cartegnie git at videolan.org
Sun Dec 25 22:48:19 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Dec 25 22:24:58 2016 +0100| [07052dd229997b5d5b8856f472378533218847bb] | committer: Francois Cartegnie

demux: libasf: strings conversion can fail

And drops empty string hack

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

 modules/demux/asf/asf.c    | 9 ++++++---
 modules/demux/asf/libasf.c | 6 +-----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 0a65dca..6c08de6 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -1013,6 +1013,8 @@ static int DemuxInit( demux_t *p_demux )
                 uint32_t i;
                 for( i = 0; i < p_meta->i_record_entries_count; i++ )
                 {
+                    if( !p_meta->record[i].psz_name )
+                        continue;
                     if( !strcmp( p_meta->record[i].psz_name, "AspectRatioX" ) )
                     {
                         if( (!i_aspect_x && !p_meta->record[i].i_stream) ||
@@ -1103,7 +1105,8 @@ static int DemuxInit( demux_t *p_demux )
         if( fmt.i_cat != UNKNOWN_ES )
         {
             if( p_esp && p_languages &&
-                p_esp->i_language_index < p_languages->i_language )
+                p_esp->i_language_index < p_languages->i_language &&
+                p_languages->ppsz_language[p_esp->i_language_index] )
             {
                 fmt.psz_language = strdup( p_languages->ppsz_language[p_esp->i_language_index] );
                 char *p;
@@ -1248,7 +1251,7 @@ static int DemuxInit( demux_t *p_demux )
         {
 
 #define set_meta( name, vlc_type ) \
-            if( !strncmp( p_ecd->ppsz_name[i], name, strlen(name) ) ) \
+            if( p_ecd->ppsz_name[i] && !strncmp( p_ecd->ppsz_name[i], name, strlen(name) ) ) \
                 vlc_meta_Set( p_sys->meta, vlc_type, p_ecd->ppsz_value[i] );
 
             set_meta( "WM/AlbumTitle",   vlc_meta_Album )
@@ -1258,7 +1261,7 @@ static int DemuxInit( demux_t *p_demux )
             else set_meta( "WM/Genre",        vlc_meta_Genre )
             else set_meta( "WM/AlbumArtist",  vlc_meta_Artist )
             else set_meta( "WM/Publisher",    vlc_meta_Publisher )
-            else if( p_ecd->ppsz_value[i] != NULL &&
+            else if( p_ecd->ppsz_value[i] != NULL && p_ecd->ppsz_name[i] &&
                     *p_ecd->ppsz_value[i] != '\0' && /* no empty value */
                     *p_ecd->ppsz_value[i] != '{'  && /* no guid value */
                     *p_ecd->ppsz_name[i] != '{' )    /* no guid name */
diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c
index a549fa5..6c1ff27 100644
--- a/modules/demux/asf/libasf.c
+++ b/modules/demux/asf/libasf.c
@@ -91,15 +91,11 @@ ASF_FUNCTION_READ_X( uint64_t, 8, GetQWLE(p_data) )
 static char *AsfObjectHelperReadString( const uint8_t *p_peek, size_t i_peek, uint8_t **pp_data, size_t i_size )
 {
     uint8_t *p_data = *pp_data;
-    char *psz_string;
+    char *psz_string = NULL;
     if( ASF_HAVE(i_size) )
     {
         psz_string = FromCharset( "UTF-16LE", p_data, i_size );
     }
-    else
-    {
-        psz_string = strdup("");
-    }
     ASF_SKIP(i_size);
     *pp_data = p_data;
     return psz_string;



More information about the vlc-commits mailing list