[vlc-commits] Abort an demux allocation failures
Rémi Denis-Courmont
git at videolan.org
Mon Jul 11 21:38:11 CEST 2011
vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 10 23:40:14 2011 +0300| [6314bbca4f31c46cf34d819c206dd640935fffc8] | committer: Rémi Denis-Courmont
Abort an demux allocation failures
(cherry picked from commit 566fe8b1e12e6f1442c51359b33f061b16327055)
Conflicts:
modules/demux/oggseek.c
modules/demux/stl.c
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=6314bbca4f31c46cf34d819c206dd640935fffc8
---
modules/demux/flac.c | 2 +-
modules/demux/nuv.c | 2 ++
modules/demux/ogg.c | 1 +
modules/demux/real.c | 10 +++++-----
modules/demux/ts.c | 14 ++++++++------
modules/demux/ty.c | 4 ++--
6 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 9ce415b..01e5be1 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -405,7 +405,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 40b5aa0..3c4d017 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -423,6 +423,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 d66c93c..6fc6a0e 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -678,6 +678,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/real.c b/modules/demux/real.c
index e3b6a07..269ded3 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -964,7 +964,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 */
@@ -1657,18 +1657,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/ts.c b/modules/demux/ts.c
index b165433..a6698ef 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -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
* 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)
@@ -559,7 +559,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 );
@@ -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->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 );
@@ -1852,6 +1852,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';
}
@@ -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 )
{
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 431c6c7..b237592 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -1899,7 +1899,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;
@@ -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;
*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