[vlc-commits] mp4: use vlc_alloc helper

Thomas Guillem git at videolan.org
Sat Nov 11 19:00:10 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sat Nov 11 18:45:23 2017 +0100| [27918a4dbf40c3bae8da54f6d65ea70d943e5bf7] | committer: Thomas Guillem

mp4: use vlc_alloc helper

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

 modules/demux/mp4/libmp4.c | 8 ++++----
 modules/demux/mp4/mp4.c    | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 2301d5ee04..e8fe51d01c 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1952,8 +1952,8 @@ static int MP4_ReadBox_sbgp( stream_t *p_stream, MP4_Box_t *p_box )
     if( p_sbgp->i_entry_count > i_read / (4 + 4) )
         p_sbgp->i_entry_count = i_read / (4 + 4);
 
-    p_sbgp->entries.pi_sample_count = malloc( p_sbgp->i_entry_count * sizeof(uint32_t) );
-    p_sbgp->entries.pi_group_description_index = malloc( p_sbgp->i_entry_count * sizeof(uint32_t) );
+    p_sbgp->entries.pi_sample_count = vlc_alloc( p_sbgp->i_entry_count, sizeof(uint32_t) );
+    p_sbgp->entries.pi_group_description_index = vlc_alloc( p_sbgp->i_entry_count, sizeof(uint32_t) );
 
     if( !p_sbgp->entries.pi_sample_count || !p_sbgp->entries.pi_group_description_index )
     {
@@ -2032,7 +2032,7 @@ static int MP4_ReadBox_sgpd( stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_GET4BYTES( p_sgpd->i_entry_count );
 
-    p_sgpd->p_entries = malloc( p_sgpd->i_entry_count * sizeof(*p_sgpd->p_entries) );
+    p_sgpd->p_entries = vlc_alloc( p_sgpd->i_entry_count, sizeof(*p_sgpd->p_entries) );
     if( !p_sgpd->p_entries )
         MP4_READBOX_EXIT( 0 );
 
@@ -2108,7 +2108,7 @@ static int MP4_ReadBox_stsdext_chan( stream_t *p_stream, MP4_Box_t *p_box )
         MP4_READBOX_EXIT( 0 );
 
     p_chan->layout.p_descriptions =
-        malloc( p_chan->layout.i_channels_description_count * i_descsize );
+        vlc_alloc( p_chan->layout.i_channels_description_count, i_descsize );
 
     if ( !p_chan->layout.p_descriptions )
         MP4_READBOX_EXIT( 0 );
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 1307a1bc29..67a1ca9633 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -397,7 +397,7 @@ static int CreateTracks( demux_t *p_demux, unsigned i_tracks )
     if( SIZE_MAX / i_tracks < sizeof(mp4_track_t) )
         return VLC_EGENERIC;
 
-    p_sys->track = malloc( i_tracks * sizeof(mp4_track_t)  );
+    p_sys->track = vlc_alloc( i_tracks, sizeof(mp4_track_t)  );
     if( p_sys->track == NULL )
         return VLC_ENOMEM;
     p_sys->i_tracks = i_tracks;
@@ -1941,7 +1941,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 return VLC_EGENERIC;
 
             *ppp_attach = (input_attachment_t**)
-                    malloc( sizeof(input_attachment_t*) * i_count );
+                    vlc_alloc( i_count, sizeof(input_attachment_t*) );
             if( !(*ppp_attach) ) return VLC_ENOMEM;
 
             /* First add cover attachments */



More information about the vlc-commits mailing list