Commit 566fe8b1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Abort an demux allocation failures

parent 1cdbc7b6
......@@ -406,7 +406,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_EGENERIC;
*pi_int = p_sys->i_attachments;;
*ppp_attach = malloc( sizeof(input_attachment_t**) * p_sys->i_attachments );
*ppp_attach = xmalloc( sizeof(input_attachment_t**) * p_sys->i_attachments );
for( i = 0; i < p_sys->i_attachments; i++ )
(*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] );
return VLC_SUCCESS;
......
......@@ -418,6 +418,8 @@ static int Demux( demux_t *p_demux )
{
/* for rtjpeg data, the header is also needed */
p_data = block_Realloc( p_data, NUV_FH_SIZE, fh.i_length );
if( unlikely(!p_data) )
abort();
memcpy( p_data->p_buffer, p_sys->fh_buffer, NUV_FH_SIZE );
}
/* 0,1,2,3 -> rtjpeg, >=4 mpeg4 */
......
......@@ -628,6 +628,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
}
else
{
#warning Memory leak
p_stream->i_headers = 0;
p_stream->p_headers = NULL;
free( p_org );
......
......@@ -78,7 +78,7 @@ static demux_index_entry_t *index_entry_delete( demux_index_entry_t *idx )
static demux_index_entry_t *index_entry_new( void )
{
demux_index_entry_t *idx = (demux_index_entry_t *)malloc( sizeof( demux_index_entry_t ) );
demux_index_entry_t *idx = xmalloc( sizeof( demux_index_entry_t ) );
idx->p_next = idx->p_prev = NULL;
idx->i_pagepos_end = -1;
return idx;
......
......@@ -963,7 +963,7 @@ static char *StreamReadString2( stream_t *s )
if( i_length <= 0 )
return NULL;
char *psz_string = calloc( 1, i_length + 1 );
char *psz_string = xcalloc( 1, i_length + 1 );
stream_Read( s, psz_string, i_length ); /* Valid even if !psz_string */
......@@ -1661,18 +1661,18 @@ static int CodecAudioParse( demux_t *p_demux, int i_tk_id, const uint8_t *p_data
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_subpacket_size;
tk->p_subpackets =
calloc( tk->i_subpackets, sizeof(block_t *) );
xcalloc( tk->i_subpackets, sizeof(block_t *) );
tk->p_subpackets_timecode =
calloc( tk->i_subpackets , sizeof( int64_t ) );
xcalloc( tk->i_subpackets , sizeof( int64_t ) );
}
else if( fmt.i_codec == VLC_CODEC_RA_288 )
{
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_coded_frame_size;
tk->p_subpackets =
calloc( tk->i_subpackets, sizeof(block_t *) );
xcalloc( tk->i_subpackets, sizeof(block_t *) );
tk->p_subpackets_timecode =
calloc( tk->i_subpackets , sizeof( int64_t ) );
xcalloc( tk->i_subpackets , sizeof( int64_t ) );
}
/* Check if the calloc went correctly */
......
......@@ -175,11 +175,11 @@ static int Open(vlc_object_t *object)
const int tti_count = ParseInteger(&header[238], 5);
msg_Dbg(demux, "Detected EBU STL : CCT=%d TTI=%d start=%8.8s %lld", cct, tti_count, &header[256], program_start);
demux_sys_t *sys = malloc(sizeof(*sys));
demux_sys_t *sys = xmalloc(sizeof(*sys));
sys->next_date = 0;
sys->current = 0;
sys->count = 0;
sys->index = calloc(tti_count, sizeof(*sys->index));
sys->index = xcalloc(tti_count, sizeof(*sys->index));
bool comment = false;
......
......@@ -503,10 +503,10 @@ static int Open( vlc_object_t *p_this )
* http://www.i-topfield.com/data/product/firmware/Structure%20of%20Recorded%20File%20in%20TF5000PVR%20(Feb%2021%202004).doc
* but after the filename the offsets seem to be incorrect. - DJ */
int i_duration, i_name;
char *psz_name = malloc(25);
char *psz_name = xmalloc(25);
char *psz_event_name;
char *psz_event_text = malloc(130);
char *psz_ext_text = malloc(1025);
char *psz_event_text = xmalloc(130);
char *psz_ext_text = xmalloc(1025);
// 2 bytes version Uimsbf (4,5)
// 2 bytes reserved (6,7)
......@@ -541,7 +541,7 @@ static int Open( vlc_object_t *p_this )
// 1 byte event name length Uimsbf (89)
i_name = (int)(p_peek[89]&~0x81);
msg_Dbg( p_demux, "event name length = %d", i_name);
psz_event_name = malloc( i_name+1 );
psz_event_name = xmalloc( i_name+1 );
// 1 byte parental rating (90)
// 129 bytes of event text
memcpy( psz_event_name, &p_peek[91], i_name );
......@@ -727,7 +727,7 @@ static int Open( vlc_object_t *p_this )
{
p_sys->i_ts_read = 1500 / p_sys->i_packet_size;
}
p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read );
p_sys->buffer = xmalloc( p_sys->i_packet_size * p_sys->i_ts_read );
}
}
free( psz_string );
......@@ -1829,6 +1829,8 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid )
}
/* Append a \0 */
p_block = block_Realloc( p_block, 0, p_block->i_buffer + 1 );
if( !p_block )
abort();
p_block->p_buffer[p_block->i_buffer -1] = '\0';
}
......@@ -2405,7 +2407,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
if( dec_descr.i_decoder_specific_info_len > 0 )
{
dec_descr.p_decoder_specific_info =
malloc( dec_descr.i_decoder_specific_info_len );
xmalloc( dec_descr.i_decoder_specific_info_len );
}
for( i = 0; i < dec_descr.i_decoder_specific_info_len; i++ )
{
......
......@@ -1892,7 +1892,7 @@ static int get_chunk_header(demux_t *p_demux)
stream_Read( p_demux->s, NULL, 4 );
/* read the record headers into a temp buffer */
p_hdr_buf = malloc(i_num_recs * 16);
p_hdr_buf = xmalloc(i_num_recs * 16);
if (stream_Read(p_demux->s, p_hdr_buf, i_num_recs * 16) < i_num_recs * 16) {
free( p_hdr_buf );
p_sys->eof = true;
......@@ -1919,7 +1919,7 @@ static ty_rec_hdr_t *parse_chunk_headers( const uint8_t *p_buf,
ty_rec_hdr_t *p_hdrs, *p_rec_hdr;
*pi_payload_size = 0;
p_hdrs = malloc(i_num_recs * sizeof(ty_rec_hdr_t));
p_hdrs = xmalloc(i_num_recs * sizeof(ty_rec_hdr_t));
for (i = 0; i < i_num_recs; i++)
{
......
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