Commit 37a2578c authored by ivoire's avatar ivoire
Browse files

Remove unneeded msg_Err.

Fix potential segfault (check malloc return value).
parent 172e22c2
......@@ -313,10 +313,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate structures */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
p_sys->b_playing = false;
p_sys->start_date = 0;
vlc_cond_init( p_aout, &p_sys->wait );
......
......@@ -83,10 +83,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate structure */
p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
p_aout->output.p_sys = p_sys;
i_err = arts_init();
......
......@@ -161,10 +161,7 @@ static int Open( vlc_object_t * p_this )
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return( VLC_ENOMEM );
}
return VLC_ENOMEM;
p_sys = p_aout->output.p_sys;
p_sys->i_default_dev = 0;
......@@ -649,10 +646,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
i_streams = i_param_size / sizeof( AudioStreamID );
p_streams = (AudioStreamID *)malloc( i_param_size );
if( p_streams == NULL )
{
msg_Err( p_aout, "out of memory" );
return false;
}
err = AudioDeviceGetProperty( p_sys->i_selected_dev, 0, FALSE,
kAudioDevicePropertyStreams,
......@@ -685,10 +679,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
if( p_format_list == NULL )
{
msg_Err( p_aout, "could not malloc the memory" );
continue;
}
err = AudioStreamGetProperty( p_streams[i], 0,
kAudioStreamPropertyPhysicalFormats,
......@@ -951,10 +942,7 @@ static void Probe( aout_instance_t * p_aout )
/* Allocate DeviceID array */
p_devices = (AudioDeviceID*)malloc( sizeof(AudioDeviceID) * p_sys->i_devices );
if( p_devices == NULL )
{
msg_Err( p_aout, "out of memory" );
goto error;
}
/* Populate DeviceID array */
err = AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
......@@ -1101,10 +1089,7 @@ static int AudioDeviceSupportsDigital( aout_instance_t *p_aout, AudioDeviceID i_
i_streams = i_param_size / sizeof( AudioStreamID );
p_streams = (AudioStreamID *)malloc( i_param_size );
if( p_streams == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
err = AudioDeviceGetProperty( i_dev_id, 0, FALSE,
kAudioDevicePropertyStreams,
......@@ -1150,10 +1135,7 @@ static int AudioStreamSupportsDigital( aout_instance_t *p_aout, AudioStreamID i_
i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
if( p_format_list == NULL )
{
msg_Err( p_aout, "could not malloc the memory" );
return false;
}
err = AudioStreamGetProperty( i_stream_id, 0,
kAudioStreamPropertyPhysicalFormats,
......
......@@ -254,10 +254,7 @@ static int OpenAudio( vlc_object_t *p_this )
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
/* Initialize some variables */
p_aout->output.p_sys->p_dsobject = NULL;
......
......@@ -91,10 +91,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate structure */
p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
p_aout->output.p_sys = p_sys;
......
......@@ -154,10 +154,7 @@ static int Open( vlc_object_t * p_this )
/* Allocate structure */
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
if( !strcmp( psz_name, "-" ) )
p_aout->output.p_sys->p_file = stdout;
......
......@@ -97,18 +97,14 @@ static int Open( vlc_object_t * p_this )
p_aout->output.p_sys = p_sys =
(aout_sys_t *)malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* New PCMAudioPlayer */
p_sys->pPlayer = pPlayer = new PCMAudioPlayer();
if( p_sys->pPlayer == NULL )
{
msg_Err( p_aout, "out of memory" );
free( p_sys );
return VLC_EGENERIC;
return VLC_ENOMEM;
}
/* Get Buffer Requirements */
......@@ -127,10 +123,9 @@ static int Open( vlc_object_t * p_this )
p_sys->ppBuffers = (void **)malloc( p_sys->nBuffers * sizeof( void * ) );
if( p_sys->ppBuffers == NULL )
{
msg_Err( p_aout, "out of memory" );
delete pPlayer;
free( p_sys );
return VLC_EGENERIC;
return VLC_ENOMEM;
}
/* Open PCMAudioPlayer */
......
......@@ -108,7 +108,6 @@ static int Open( vlc_object_t *p_this )
p_sys = calloc( 1, sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
status = VLC_ENOMEM;
goto error_out;
}
......@@ -143,7 +142,6 @@ static int Open( vlc_object_t *p_this )
sizeof(jack_port_t *) );
if( p_sys->p_jack_ports == NULL )
{
msg_Err( p_aout, "out of memory" );
status = VLC_ENOMEM;
goto error_out;
}
......@@ -152,7 +150,6 @@ static int Open( vlc_object_t *p_this )
sizeof(jack_sample_t *) );
if( p_sys->p_jack_buffers == NULL )
{
msg_Err( p_aout, "out of memory" );
status = VLC_ENOMEM;
goto error_out;
}
......
......@@ -279,10 +279,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate structure */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
/* Get device name */
if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL )
......
......@@ -181,10 +181,7 @@ static int Open( vlc_object_t * p_this )
/* Allocate p_sys structure */
p_sys = (aout_sys_t *)malloc( sizeof(aout_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_aout = p_aout;
p_sys->p_stream = 0;
p_aout->output.p_sys = p_sys;
......
......@@ -245,10 +245,7 @@ static int Open( vlc_object_t *p_this )
p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->output.p_sys == NULL )
{
msg_Err( p_aout, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_aout->output.pf_play = Play;
p_aout->b_die = false;
......@@ -411,7 +408,6 @@ static int Open( vlc_object_t *p_this )
if( p_aout->output.p_sys->p_silence_buffer == NULL )
{
free( p_aout->output.p_sys );
msg_Err( p_aout, "out of memory" );
return 1;
}
p_aout->output.p_sys->i_repeat_counter = 0;
......
......@@ -100,7 +100,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
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;
}
......@@ -139,12 +138,15 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
p_sys->p_context->extradata =
malloc( p_sys->p_context->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE );
memcpy( p_sys->p_context->extradata,
(char*)p_dec->fmt_in.p_extra + i_offset,
p_sys->p_context->extradata_size );
memset( (char*)p_sys->p_context->extradata +
p_sys->p_context->extradata_size, 0,
FF_INPUT_BUFFER_PADDING_SIZE );
if( p_sys->p_context->extradata )
{
memcpy( p_sys->p_context->extradata,
(char*)p_dec->fmt_in.p_extra + i_offset,
p_sys->p_context->extradata_size );
memset( (char*)p_sys->p_context->extradata +
p_sys->p_context->extradata_size, 0,
FF_INPUT_BUFFER_PADDING_SIZE );
}
}
else
p_sys->p_context->extradata = NULL;
......
......@@ -84,7 +84,6 @@ int OpenDeinterlace( vlc_object_t *p_this )
if( ( p_filter->p_sys = p_sys =
(filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
......
......@@ -253,10 +253,7 @@ int OpenEncoder( vlc_object_t *p_this )
/* Allocate the memory needed to store the encoder'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;
p_sys->p_codec = p_codec;
......
......@@ -232,7 +232,6 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
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;
}
memset( p_sys, 0, sizeof(decoder_sys_t) );
......
......@@ -108,7 +108,6 @@ static int OpenDecoder( vlc_object_t *p_this )
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;
}
......
......@@ -520,7 +520,6 @@ static int DecOpen( vlc_object_t *p_this )
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
goto error;
}
......@@ -1341,7 +1340,6 @@ static int EncOpen( vlc_object_t *p_this )
if( ( p_enc->p_sys = p_sys =
(encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
{
msg_Err( p_enc, "out of memory" );
goto error;
}
......
......@@ -1664,10 +1664,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_ENOMEM;
}
p_enc->p_sys = p_sys;
p_enc->pf_encode_sub = Encode;
......
......@@ -160,10 +160,7 @@ static int OpenDecoder( 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 ) );
......
......@@ -79,7 +79,6 @@ static int OpenDecoder( vlc_object_t *p_this )
if( ( p_dec->p_sys = p_sys =
(decoder_sys_t *)calloc(1, sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_ENOMEM;
}
......@@ -400,7 +399,6 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
p_text_region->psz_html = strndup( psz_subtitle, i_len );
if( ! p_text_region->psz_html )
{
msg_Err( p_dec, "out of memory" );
p_spu->pf_destroy_region( VLC_OBJECT(p_dec), p_text_region );
return NULL;
}
......@@ -649,7 +647,6 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
p_style = calloc( 1, sizeof(ssa_style_t) );
if( ! p_style )
{
msg_Err( p_dec, "out of memory" );
free( psz_node );
break;
}
......
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