Commit 964e1c13 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

mp4: handle memory error and cleanup

parent b7a62ba5
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment