[vlc-commits] mp4: handle memory error and cleanup
Rémi Denis-Courmont
git at videolan.org
Fri Nov 24 20:54:28 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov 23 20:23:30 2017 +0200| [964e1c13f2856511d54752779a85fd1f7c5a5c0e] | committer: Rémi Denis-Courmont
mp4: handle memory error and cleanup
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=964e1c13f2856511d54752779a85fd1f7c5a5c0e
---
modules/demux/mp4/libmp4.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 2d98c6a342..53ff41f3cb 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -872,25 +872,31 @@ static int MP4_ReadBox_sidx( stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET8BYTES( p_sidx_data->i_first_offset );
}
- uint16_t i_reserved;
+ uint16_t i_reserved, i_count;
+
VLC_UNUSED(i_reserved);
MP4_GET2BYTES( i_reserved );
- MP4_GET2BYTES( p_sidx_data->i_reference_count );
- uint16_t i_count = p_sidx_data->i_reference_count;
+ MP4_GET2BYTES( i_count );
+
+ p_sidx_data->i_reference_count = i_count;
+ p_sidx_data->p_items = vlc_alloc( i_count, sizeof( MP4_Box_sidx_item_t ) );
+ if( unlikely(p_sidx_data->p_items == NULL) )
+ MP4_READBOX_EXIT( 0 );
- p_sidx_data->p_items = calloc( i_count, sizeof( MP4_Box_sidx_item_t ) );
- uint32_t tmp;
for( unsigned i = 0; i < i_count; i++ )
{
+ MP4_Box_sidx_item_t *item = p_sidx_data->p_items + i;
+ uint32_t tmp;
+
MP4_GET4BYTES( tmp );
- p_sidx_data->p_items[i].b_reference_type = (bool)((tmp & 0x80000000)>>24);
- p_sidx_data->p_items[i].i_referenced_size = tmp & 0x7fffffff;
- MP4_GET4BYTES( p_sidx_data->p_items[i].i_subsegment_duration );
+ item->b_reference_type = tmp >> 31;
+ item->i_referenced_size = tmp & 0x7fffffff;
+ MP4_GET4BYTES( item->i_subsegment_duration );
MP4_GET4BYTES( tmp );
- p_sidx_data->p_items[i].b_starts_with_SAP = (bool)((tmp & 0x80000000)>>24);
- p_sidx_data->p_items[i].i_SAP_type = (tmp & 0x70000000)>>24;
- p_sidx_data->p_items[i].i_SAP_delta_time = tmp & 0xfffffff;
+ item->b_starts_with_SAP = tmp >> 31;
+ item->i_SAP_type = (tmp >> 24) & 0x70;
+ item->i_SAP_delta_time = tmp & 0xfffffff;
}
#ifdef MP4_VERBOSE
More information about the vlc-commits
mailing list