]> git.sesse.net Git - vlc/blobdiff - modules/demux/mp4/libmp4.c
Fix some brain-damaged calloc use
[vlc] / modules / demux / mp4 / libmp4.c
index 60057b9bdac94784b9a33451a751990a0a28394e..6fe3657d823bdb4df37bce0b0d62329010b08c26 100644 (file)
@@ -67,7 +67,7 @@
     if( (i_read > 0) && (p_peek[0]) )   \
     {       \
         const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 );  \
-        p_str = calloc( sizeof(char), __i_copy__+1 );               \
+        p_str = malloc( __i_copy__+1 );               \
         if( __i_copy__ > 0 ) memcpy( p_str, p_peek, __i_copy__ );   \
         p_str[__i_copy__] = 0;      \
         p_peek += __i_copy__ + 1;   \
@@ -136,6 +136,8 @@ static void CreateUUID( UUID_t *p_uuid, uint32_t i_fourcc )
     /* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
             where XXXXXXXX is the fourcc */
     /* FIXME implement this */
+    (void)p_uuid;
+    (void)i_fourcc;
 }
 
 /* some functions for mp4 encoding of variables */
@@ -319,6 +321,7 @@ static int MP4_ReadBoxContainer( stream_t *p_stream, MP4_Box_t *p_container )
 static void MP4_FreeBox_Common( MP4_Box_t *p_box )
 {
     /* Up to now do nothing */
+    (void)p_box;
 }
 
 static int MP4_ReadBoxSkip( stream_t *p_stream, MP4_Box_t *p_box )
@@ -600,7 +603,7 @@ static int MP4_ReadBox_hdlr( stream_t *p_stream, MP4_Box_t *p_box )
 
     if( i_read > 0 )
     {
-        p_box->data.p_hdlr->psz_name = calloc( sizeof( char ), i_read + 1 );
+        p_box->data.p_hdlr->psz_name = malloc( i_read + 1 );
 
         /* Yes, I love .mp4 :( */
         if( p_box->data.p_hdlr->i_predefined == VLC_FOURCC( 'm', 'h', 'l', 'r' ) )
@@ -887,7 +890,7 @@ static int MP4_ReadBox_esds( stream_t *p_stream, MP4_Box_t *p_box )
             unsigned int i_len;
 
             MP4_GET1BYTE( i_len );
-            es_descriptor.psz_URL = calloc( sizeof(char), i_len + 1 );
+            es_descriptor.psz_URL = malloc( i_len + 1 );
             memcpy( es_descriptor.psz_URL, p_peek, i_len );
             es_descriptor.psz_URL[i_len] = 0;
             p_peek += i_len;
@@ -2055,16 +2058,8 @@ static int MP4_ReadBox_drms( stream_t *p_stream, MP4_Box_t *p_box )
 
     if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms )
     {
-        int i_ret;
-        if( config_GetInt( p_stream, "france" ) )
-        {
-            i_ret = -7;
-        }
-        else
-        {
-            i_ret= drms_init( p_drms_box->data.p_sample_soun->p_drms,
+        int i_ret = drms_init( p_drms_box->data.p_sample_soun->p_drms,
                                p_box->i_type, p_peek, i_read );
-        }
         if( i_ret )
         {
             const char *psz_error;
@@ -2077,7 +2072,6 @@ static int MP4_ReadBox_drms( stream_t *p_stream, MP4_Box_t *p_box )
                 case -4: psz_error = "could not get SCI data"; break;
                 case -5: psz_error = "no user key found in SCI data"; break;
                 case -6: psz_error = "invalid user key"; break;
-                case -7: psz_error = "you live in France"; break;
                 default: psz_error = "unknown error"; break;
             }
             if MP4_BOX_TYPE_ASCII()
@@ -2338,7 +2332,7 @@ unknown:
 /****                   "Higher level" Functions                          ****/
 /**** ------------------------------------------------------------------- ****/
 
-static struct
+static const struct
 {
     uint32_t i_type;
     int  (*MP4_ReadBox_function )( stream_t *p_stream, MP4_Box_t *p_box );
@@ -2808,7 +2802,8 @@ static void __MP4_BoxGet( MP4_Box_t **pp_result,
         return;
     }
 
-    vasprintf( &psz_path, psz_fmt, args );
+    if( vasprintf( &psz_path, psz_fmt, args ) == -1 )
+        psz_path = NULL;
 
     if( !psz_path || !psz_path[0] )
     {