Fix potential segfault (check malloc return value).
/* 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 );
/* 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();
/* 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;
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,
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,
/* 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,
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,
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,
/* 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;
/* 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;
/* 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;
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 */
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 */
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;
}
sizeof(jack_port_t *) );
if( p_sys->p_jack_ports == NULL )
{
- msg_Err( p_aout, "out of memory" );
status = VLC_ENOMEM;
goto error_out;
}
sizeof(jack_sample_t *) );
if( p_sys->p_jack_buffers == NULL )
{
- msg_Err( p_aout, "out of memory" );
status = VLC_ENOMEM;
goto error_out;
}
/* 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 )
/* 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;
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;
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;
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;
}
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;
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;
}
/* 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;
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) );
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;
}
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;
}
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;
}
/* 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;
/* 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 ) );
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;
}
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;
}
p_style = calloc( 1, sizeof(ssa_style_t) );
if( ! p_style )
{
- msg_Err( p_dec, "out of memory" );
free( psz_node );
break;
}
{
avi_track_t *tk = malloc( sizeof( avi_track_t ) );
if( !tk )
- {
- msg_Err( p_demux, "Out of memory" );
goto error;
- }
avi_chunk_list_t *p_strl = AVI_ChunkFind( p_hdrl, AVIFOURCC_strl, i );
avi_chunk_strh_t *p_strh = AVI_ChunkFind( p_strl, AVIFOURCC_strh, 0 );
i--;
}
p_line = malloc( i + 1 );
- if( NULL == p_line )
- {
- msg_Err( p_demux, "out of memory" );
+ if( p_line == NULL )
return NULL;
- }
strncpy ( p_line, (char*)p_buf, i );
p_line[i] = '\0';
// msg_Dbg( p_demux, "i = %d, pos = %d, %s", i, *p_pos, p_line );
strlen(p_demux->p_sys->psz_base) +
strlen(psz_uri) +1 );
if( !psz_tmp )
- {
- msg_Err( p_demux, "out of memory");
return false;
- }
sprintf( psz_tmp, "%s%s",
p_demux->p_sys->psz_base, psz_uri );
free( psz_uri );
if( !( p_sys->subtitle = realloc( p_sys->subtitle,
sizeof(subtitle_t) * i_max ) ) )
{
- msg_Err( p_demux, "out of memory");
free( p_sys->subtitle );
TextUnload( &p_sys->txt );
free( p_sys );
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+ if( !p_sys )
+ return VLC_ENOMEM;
p_sys->psz_header = NULL;
p_sys->i_subtitle = 0;
p_sys->i_subtitles = 0;
p_data = malloc( i_ssize );
if( !p_data )
{
- msg_Err( p_demux, "out of memory");
free( p_sys );
return VLC_ENOMEM;
}
if( !( p_sys->subtitle = realloc( p_sys->subtitle, sizeof(subtitle_t)
* p_sys->i_subs_alloc ) ) )
{
- msg_Err( p_demux, "out of memory");
return VLC_ENOMEM;
}
}