Commit 6314bbca authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Abort an demux allocation failures

(cherry picked from commit 566fe8b1e12e6f1442c51359b33f061b16327055)

Conflicts:

	modules/demux/oggseek.c
	modules/demux/stl.c
parent f38f9dbc
...@@ -405,7 +405,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -405,7 +405,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_EGENERIC; return VLC_EGENERIC;
*pi_int = p_sys->i_attachments;; *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++ ) for( i = 0; i < p_sys->i_attachments; i++ )
(*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] ); (*ppp_attach)[i] = vlc_input_attachment_Duplicate( p_sys->attachments[i] );
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -423,6 +423,8 @@ static int Demux( demux_t *p_demux ) ...@@ -423,6 +423,8 @@ static int Demux( demux_t *p_demux )
{ {
/* for rtjpeg data, the header is also needed */ /* for rtjpeg data, the header is also needed */
p_data = block_Realloc( p_data, NUV_FH_SIZE, fh.i_length ); 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 ); memcpy( p_data->p_buffer, p_sys->fh_buffer, NUV_FH_SIZE );
} }
/* 0,1,2,3 -> rtjpeg, >=4 mpeg4 */ /* 0,1,2,3 -> rtjpeg, >=4 mpeg4 */
......
...@@ -678,6 +678,7 @@ static void Ogg_DecodePacket( demux_t *p_demux, ...@@ -678,6 +678,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
} }
else else
{ {
#warning Memory leak
p_stream->i_headers = 0; p_stream->i_headers = 0;
p_stream->p_headers = NULL; p_stream->p_headers = NULL;
free( p_org ); free( p_org );
......
...@@ -964,7 +964,7 @@ static char *StreamReadString2( stream_t *s ) ...@@ -964,7 +964,7 @@ static char *StreamReadString2( stream_t *s )
if( i_length <= 0 ) if( i_length <= 0 )
return NULL; 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 */ stream_Read( s, psz_string, i_length ); /* Valid even if !psz_string */
...@@ -1657,18 +1657,18 @@ static int CodecAudioParse( demux_t *p_demux, int i_tk_id, const uint8_t *p_data ...@@ -1657,18 +1657,18 @@ static int CodecAudioParse( demux_t *p_demux, int i_tk_id, const uint8_t *p_data
tk->i_subpackets = tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_subpacket_size; i_subpacket_h * i_frame_size / tk->i_subpacket_size;
tk->p_subpackets = tk->p_subpackets =
calloc( tk->i_subpackets, sizeof(block_t *) ); xcalloc( tk->i_subpackets, sizeof(block_t *) );
tk->p_subpackets_timecode = 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 ) else if( fmt.i_codec == VLC_CODEC_RA_288 )
{ {
tk->i_subpackets = tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_coded_frame_size; i_subpacket_h * i_frame_size / tk->i_coded_frame_size;
tk->p_subpackets = tk->p_subpackets =
calloc( tk->i_subpackets, sizeof(block_t *) ); xcalloc( tk->i_subpackets, sizeof(block_t *) );
tk->p_subpackets_timecode = tk->p_subpackets_timecode =
calloc( tk->i_subpackets , sizeof( int64_t ) ); xcalloc( tk->i_subpackets , sizeof( int64_t ) );
} }
/* Check if the calloc went correctly */ /* Check if the calloc went correctly */
......
...@@ -521,10 +521,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -521,10 +521,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 * 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 */ * but after the filename the offsets seem to be incorrect. - DJ */
int i_duration, i_name; int i_duration, i_name;
char *psz_name = malloc(25); char *psz_name = xmalloc(25);
char *psz_event_name; char *psz_event_name;
char *psz_event_text = malloc(130); char *psz_event_text = xmalloc(130);
char *psz_ext_text = malloc(1025); char *psz_ext_text = xmalloc(1025);
// 2 bytes version Uimsbf (4,5) // 2 bytes version Uimsbf (4,5)
// 2 bytes reserved (6,7) // 2 bytes reserved (6,7)
...@@ -559,7 +559,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -559,7 +559,7 @@ static int Open( vlc_object_t *p_this )
// 1 byte event name length Uimsbf (89) // 1 byte event name length Uimsbf (89)
i_name = (int)(p_peek[89]&~0x81); i_name = (int)(p_peek[89]&~0x81);
msg_Dbg( p_demux, "event name length = %d", i_name); 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) // 1 byte parental rating (90)
// 129 bytes of event text // 129 bytes of event text
memcpy( psz_event_name, &p_peek[91], i_name ); memcpy( psz_event_name, &p_peek[91], i_name );
...@@ -747,7 +747,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -747,7 +747,7 @@ static int Open( vlc_object_t *p_this )
{ {
p_sys->i_ts_read = 1500 / p_sys->i_packet_size; 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 ); free( psz_string );
...@@ -1852,6 +1852,8 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid ) ...@@ -1852,6 +1852,8 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid )
} }
/* Append a \0 */ /* Append a \0 */
p_block = block_Realloc( p_block, 0, p_block->i_buffer + 1 ); 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'; p_block->p_buffer[p_block->i_buffer -1] = '\0';
} }
...@@ -2428,7 +2430,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2428,7 +2430,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
if( dec_descr.i_decoder_specific_info_len > 0 ) if( dec_descr.i_decoder_specific_info_len > 0 )
{ {
dec_descr.p_decoder_specific_info = 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++ ) for( i = 0; i < dec_descr.i_decoder_specific_info_len; i++ )
{ {
......
...@@ -1899,7 +1899,7 @@ static int get_chunk_header(demux_t *p_demux) ...@@ -1899,7 +1899,7 @@ static int get_chunk_header(demux_t *p_demux)
stream_Read( p_demux->s, NULL, 4 ); stream_Read( p_demux->s, NULL, 4 );
/* read the record headers into a temp buffer */ /* 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) { if (stream_Read(p_demux->s, p_hdr_buf, i_num_recs * 16) < i_num_recs * 16) {
free( p_hdr_buf ); free( p_hdr_buf );
p_sys->eof = true; p_sys->eof = true;
...@@ -1926,7 +1926,7 @@ static ty_rec_hdr_t *parse_chunk_headers( const uint8_t *p_buf, ...@@ -1926,7 +1926,7 @@ static ty_rec_hdr_t *parse_chunk_headers( const uint8_t *p_buf,
ty_rec_hdr_t *p_hdrs, *p_rec_hdr; ty_rec_hdr_t *p_hdrs, *p_rec_hdr;
*pi_payload_size = 0; *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++) 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