Commit f5266ccf authored by Rémi Duraffort's avatar Rémi Duraffort

Don't print a message when an memory error occure and check some malloc return values.

parent 93a5f233
......@@ -124,10 +124,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_sys->b_packetizer = false;
......
......@@ -167,10 +167,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
switch( p_dec->fmt_in.i_codec )
{
......
......@@ -227,10 +227,7 @@ static int DecoderOpen( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_sys->p_logtos16 = NULL;
......@@ -1424,10 +1421,7 @@ static int EncoderOpen( vlc_object_t *p_this )
/* Allocate the memory needed to store the encoder's structure */
if( ( p_enc->p_sys = p_sys =
(encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->pf_encode_audio = EncoderEncode;
p_enc->fmt_in.i_codec = p_enc->fmt_out.i_codec;
......
......@@ -199,10 +199,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
p_dec->p_sys = p_sys = malloc( sizeof( *p_sys ) );
if( p_sys == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
/* init of p_sys */
memset( p_sys, 0, sizeof( *p_sys ) );
......@@ -1110,6 +1107,8 @@ static char *Eia608Text( eia608_t *h, bool b_html )
/* We allocate a buffer big enough for normal case */
psz = malloc( i_size );
if( !psz )
return NULL;
*psz = '\0';
if( b_html )
Eia608Strlcat( psz, "<text>", i_size );
......
......@@ -103,10 +103,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
p_dec->p_sys = p_sys = malloc(sizeof(decoder_sys_t));
if( !p_sys )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Init */
memset( p_sys, 0, sizeof(*p_sys) );
......
......@@ -116,10 +116,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
memset( &p_sys->context, 0, sizeof( cinepak_context_t ) );
var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
......@@ -448,6 +445,8 @@ static int cinepak_decode_frame( cinepak_context_t *p_context,
{
p_context->p_pix[i] = malloc( p_context->i_stride[i] *
p_context->i_lines[i] );
if( p_context->p_pix[i] == NULL )
return -1;
/* Set it to all black */
memset( p_context->p_pix[i], ( i == 0 ) ? 0 : 128 ,
p_context->i_stride[i] * p_context->i_lines[i] );
......
......@@ -126,10 +126,7 @@ static int Create( vlc_object_t *p_this )
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
if( !p_sys )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
memset( &p_dec->p_sys->fmt_cached, 0, sizeof( p_dec->p_sys->fmt_cached ) );
p_sys->pf_push_packet = p_streamext->push_packet;
......@@ -180,7 +177,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_spu->p_sys = malloc( sizeof( subpicture_sys_t ));
if( !p_spu->p_sys )
{
msg_Err( p_dec, "out of memory" );
p_dec->pf_spu_buffer_del( p_dec, p_spu );
block_Release( *pp_block );
*pp_block = NULL;
......@@ -192,7 +188,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_spu->p_sys->p_subs_data = malloc( p_block->i_buffer );
if( !p_spu->p_sys->p_subs_data )
{
msg_Err( p_dec, "out of memory" );
free( p_spu->p_sys );
p_dec->pf_spu_buffer_del( p_dec, p_spu );
block_Release( *pp_block );
......
......@@ -117,6 +117,8 @@ static int DecoderOpen( vlc_object_t *p_this )
}
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->b_packetizer = false;
......
......@@ -110,10 +110,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_sys->p_dirac = p_dirac;
......@@ -345,10 +342,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
memset( p_sys, 0, sizeof(encoder_sys_t) );
p_enc->p_sys = p_sys;
......
......@@ -124,10 +124,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_sys->b_packetizer = false;
......
......@@ -303,10 +303,7 @@ static int Open( vlc_object_t *p_this )
p_dec->pf_decode_sub = Decode;
p_sys = p_dec->p_sys = malloc( sizeof(decoder_sys_t) );
if( !p_sys )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
memset( p_sys, 0, sizeof(decoder_sys_t) );
p_sys->i_pts = (mtime_t) 0;
......@@ -634,7 +631,9 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
#ifdef DEBUG_DVBSUB
msg_Dbg( p_dec, "new clut: %i", i_id );
#endif
p_clut = malloc( sizeof(dvbsub_clut_t) );
p_clut = malloc( sizeof( dvbsub_clut_t ) );
if( !p_clut )
return;
p_clut->p_next = p_sys->p_cluts;
p_sys->p_cluts = p_clut;
}
......@@ -772,6 +771,8 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
#endif
/* Allocate a new page */
p_sys->p_page = malloc( sizeof(dvbsub_page_t) );
if( !p_sys->p_page )
return;
}
p_sys->p_page->i_version = i_version;
......
......@@ -127,10 +127,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Open a faad context */
if( ( p_sys->hfaad = faacDecOpen() ) == NULL )
......
......@@ -214,10 +214,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
/* Misc init */
aout_DateSet( &p_sys->end_date, 0 );
......@@ -1230,10 +1227,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_audio = Encode;
p_enc->fmt_out.i_codec = VLC_FOURCC('f','l','a','c');
......
......@@ -159,10 +159,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
/* init of p_sys */
#ifdef ENABLE_PACKETIZER
......
......@@ -113,10 +113,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_sys->b_packetizer = false;
......
......@@ -97,10 +97,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_sys->i_pts = 0;
p_sys->b_inited = false;
......
......@@ -152,10 +152,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_sys->b_packetizer = false;
......
......@@ -79,10 +79,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Set output properties */
p_dec->fmt_out.i_cat = VIDEO_ES;
......@@ -217,6 +214,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
/* Decode picture */
p_row_pointers = malloc( sizeof(png_bytep) * i_height );
if( !p_row_pointers )
goto error;
for( i = 0; i < (int)i_height; i++ )
p_row_pointers[i] = p_pic->p->p_pixels + p_pic->p->i_pitch * i;
......
......@@ -462,6 +462,8 @@ static int OpenAudio( decoder_t *p_dec )
p_sys->i_buffer = 0;
p_sys->i_buffer_size = 100*1000;
p_sys->p_buffer = malloc( p_sys->i_buffer_size );
if( !p_sys->p_buffer )
goto exit_error;
p_sys->i_out = 0;
p_sys->i_out_frames = 0;
......@@ -621,6 +623,8 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
static int OpenVideo( decoder_t *p_dec )
{
decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
#ifndef WIN32
vlc_mutex_t *lock;
......@@ -716,6 +720,8 @@ static int OpenVideo( decoder_t *p_dec )
/* codec data FIXME use codec not SVQ3 */
msg_Dbg( p_dec, "vide = %d", i_vide );
id = malloc( sizeof( ImageDescription ) + ( i_vide - 70 ) );
if( !id )
goto exit_error;
id->idSize = sizeof( ImageDescription ) + ( i_vide - 70 );
id->cType = FCC( fcc[0], fcc[1], fcc[2], fcc[3] );
id->version = GetWBE ( p_vide + 0 );
......@@ -752,6 +758,8 @@ static int OpenVideo( decoder_t *p_dec )
memcpy( *p_sys->framedescHandle, id, id->idSize );
p_sys->plane = malloc( p_dec->fmt_in.video.i_width * p_dec->fmt_in.video.i_height * 3 );
if( !p_sys->plane )
goto exit_error;
i_result = p_sys->QTNewGWorldFromPtr( &p_sys->OutBufferGWorld,
/*pixel format of new GWorld==YUY2 */
......
......@@ -132,10 +132,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
p_dec->p_sys->b_packetizer = false;
p_sys->i_pts = 0;
......@@ -338,6 +335,8 @@ static block_t *SendFrame( decoder_t *p_dec, block_t *p_block )
}
p_tmp = malloc( pic.p[0].i_pitch );
if( !p_tmp )
return p_block;
p_pixels = p_block->p_buffer;
for( i = 0; i < pic.i_planes; i++ )
{
......
......@@ -201,6 +201,8 @@ static int Open( vlc_object_t *p_this )
}
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
memset( p_sys, 0, sizeof(decoder_sys_t) );
/* Flavor for SIPR codecs */
......@@ -236,6 +238,11 @@ static int Open( vlc_object_t *p_this )
p_dec->pf_decode_audio = Decode;
p_sys->p_out = malloc( 4096 * 10 );
if( !p_sys->p_out )
{
free( p_sys );
return VLC_ENOMEM;
}
p_sys->i_out = 0;
return VLC_SUCCESS;
......
......@@ -108,10 +108,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_sys->psz_sdl_type = p_supported_fmt[i].psz_sdl_type;
/* Set output properties - this is a decoy and isn't used anywhere */
......
......@@ -144,10 +144,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_dec->p_sys->bits.buf_size = 0;
p_dec->p_sys->b_packetizer = false;
p_dec->p_sys->rtp_rate = p_dec->fmt_in.audio.i_rate;
......@@ -865,10 +862,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_audio = Encode;
p_enc->fmt_in.i_codec = AOUT_FMT_S16_NE;
......
......@@ -101,10 +101,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Set output properties */
p_dec->fmt_out.i_cat = VIDEO_ES;
......
......@@ -183,10 +183,7 @@ static int Open( vlc_object_t *p_this )
p_dec->pf_decode_sub = Decode;
p_sys = p_dec->p_sys = malloc( sizeof(decoder_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
memset( p_sys, 0, sizeof(decoder_sys_t) );
......
......@@ -141,10 +141,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_dec->p_sys->b_packetizer = false;
p_sys->i_pts = 0;
......@@ -612,10 +609,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_video = Encode;
......
......@@ -160,10 +160,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_audio = Encode;
......
......@@ -244,10 +244,7 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Misc init */
aout_DateSet( &p_sys->end_date, 0 );
......@@ -874,10 +871,7 @@ static int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_audio = Encode;
......
......@@ -769,6 +769,8 @@ static int Open ( vlc_object_t *p_this )
p_enc->pf_encode_video = Encode;
p_enc->pf_encode_audio = NULL;
p_enc->p_sys = p_sys = malloc( sizeof( encoder_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->i_interpolated_dts = 0;
p_sys->psz_stat_name = NULL;
......
......@@ -388,10 +388,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
p_pic = ( picture_t * ) malloc( sizeof( picture_t ) );
if( !p_pic )
{
msg_Err( p_dec, "out of memory" );
goto error;
}
memset( &fmt_in, 0, sizeof( video_format_t ) );
memset( p_pic, 0, sizeof( picture_t ) );
......
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