[vlc-commits] Abort an demux allocation failures
Rémi Denis-Courmont
git at videolan.org
Mon Jul 11 21:29:47 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 10 23:40:14 2011 +0300| [566fe8b1e12e6f1442c51359b33f061b16327055] | committer: Rémi Denis-Courmont
Abort an demux allocation failures
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=566fe8b1e12e6f1442c51359b33f061b16327055
---
modules/demux/flac.c | 2 +-
modules/demux/nuv.c | 2 ++
modules/demux/ogg.c | 1 +
modules/demux/oggseek.c | 2 +-
modules/demux/real.c | 10 +++++-----
modules/demux/stl.c | 4 ++--
modules/demux/ts.c | 14 ++++++++------
modules/demux/ty.c | 4 ++--
8 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 0f01695..5434dd0 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -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;
diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c
index 853544d..028e071 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -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 */
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 2ab4a3f..e659b9c 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -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 );
diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index abe2a6b..8f34ab5 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -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;
diff --git a/modules/demux/real.c b/modules/demux/real.c
index 3ba0a86..a295f2b 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -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 */
diff --git a/modules/demux/stl.c b/modules/demux/stl.c
index 9e40156..a0a9dd5 100644
--- a/modules/demux/stl.c
+++ b/modules/demux/stl.c
@@ -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;
diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index 375b090..9a7611a 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -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++ )
{
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index a9e0d2a..e916b41 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -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++)
{
More information about the vlc-commits
mailing list