[vlc-devel] [RFC 34/38] demux/avi: replaced usage of xcalloc

Filip Roséen filip at videolabs.io
Mon Jun 27 13:43:45 CEST 2016


---
 modules/demux/avi/libavi.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index 3159e02..3226c92 100644
--- a/modules/demux/avi/libavi.c
+++ b/modules/demux/avi/libavi.c
@@ -576,7 +576,10 @@ static int AVI_ChunkRead_idx1( stream_t *s, avi_chunk_t *p_chk )
     p_chk->idx1.i_entry_max   = i_count;
     if( i_count > 0 )
     {
-        p_chk->idx1.entry = xcalloc( i_count, sizeof( idx1_entry_t ) );
+        p_chk->idx1.entry = calloc( i_count, sizeof( idx1_entry_t ) );
+
+        if( unlikely( !p_chk->idx1.entry ) )
+            AVI_READCHUNK_EXIT( VLC_ENOMEM );
 
         for( i_index = 0; i_index < i_count ; i_index++ )
         {
@@ -630,7 +633,10 @@ static int AVI_ChunkRead_indx( stream_t *s, avi_chunk_t *p_chk )
 
         i_count = __MIN( p_indx->i_entriesinuse, i_read / 8 );
         p_indx->i_entriesinuse = i_count;
-        p_indx->idx.std = xcalloc( i_count, sizeof( indx_std_entry_t ) );
+        p_indx->idx.std = calloc( i_count, sizeof( indx_std_entry_t ) );
+
+        if( unlikely( !p_indx->idx.std ) )
+            AVI_READCHUNK_EXIT( VLC_ENOMEM );
 
         for( i = 0; i < i_count; i++ )
         {
@@ -645,7 +651,11 @@ static int AVI_ChunkRead_indx( stream_t *s, avi_chunk_t *p_chk )
 
         i_count = __MIN( p_indx->i_entriesinuse, i_read / 12 );
         p_indx->i_entriesinuse = i_count;
-        p_indx->idx.field = xcalloc( i_count, sizeof( indx_field_entry_t ) );
+        p_indx->idx.field = calloc( i_count, sizeof( indx_field_entry_t ) );
+
+        if( unlikely( !p_indx->idx.field ) )
+            AVI_READCHUNK_EXIT( VLC_ENOMEM );
+
         for( i = 0; i < i_count; i++ )
         {
             AVI_READ4BYTES( p_indx->idx.field[i].i_offset );
@@ -662,7 +672,10 @@ static int AVI_ChunkRead_indx( stream_t *s, avi_chunk_t *p_chk )
 
         i_count = __MIN( p_indx->i_entriesinuse, i_read / 16 );
         p_indx->i_entriesinuse = i_count;
-        p_indx->idx.super = xcalloc( i_count, sizeof( indx_super_entry_t ) );
+        p_indx->idx.super = calloc( i_count, sizeof( indx_super_entry_t ) );
+
+        if( unlikely( !p_indx->idx.super ) )
+            AVI_READCHUNK_EXIT( VLC_ENOMEM );
 
         for( i = 0; i < i_count; i++ )
         {
-- 
2.9.0



More information about the vlc-devel mailing list