Commit 7eaca895 authored by Rémi Duraffort's avatar Rémi Duraffort

Check malloc return value when needed and don't print an error when such error happend.

Fix a potential segfault.
parent fa781f22
......@@ -90,10 +90,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return( 1 );
}
/* Don't parse any options, but take $AAOPTS into account */
aa_parseoptions( NULL, NULL, NULL, NULL );
......
......@@ -163,10 +163,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
p_vout->p_sys->p_cv = cucul_create_canvas(0, 0);
if( !p_vout->p_sys->p_cv )
......
......@@ -89,10 +89,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
if( !p_sys )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_directfb = NULL;
p_sys->p_primary = NULL;
......
......@@ -186,10 +186,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate instance and initialize some members */
p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
};
memset( p_sys, 0, sizeof(vout_sys_t) );
p_vout->pf_init = Init;
......@@ -874,8 +871,6 @@ static int OpenDisplay( vout_thread_t *p_vout )
p_sys->p_palette = malloc( 8 * 256 * sizeof( uint16_t ) );
if( !p_sys->p_palette )
{
msg_Err( p_vout, "out of memory" );
/* Restore fb config */
ioctl( p_sys->i_fd, FBIOPUT_VSCREENINFO, &p_sys->old_info );
......
......@@ -104,10 +104,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return( 1 );
}
/* Open and initialize device */
if( OpenDisplay( p_vout ) )
......
......@@ -96,10 +96,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return( 1 );
}
/* Open and initialize device */
if( OpenDisplay( p_vout ) )
......
......@@ -97,10 +97,7 @@ static int Create( vlc_object_t *p_this )
p_vout->p_sys = (struct vout_sys_t*) malloc( sizeof(struct vout_sys_t) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
/* Allocate a screen for VLC vout. */
p_vout->p_sys->p_screen = new CascadeScreen();
......
......@@ -315,6 +315,9 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
psz_prefix = psz_tmp;
psz_filename = (char *)malloc( 10 + strlen( psz_prefix )
+ strlen( p_vout->p_sys->psz_format ) );
if( !psz_filename )
return;
if( p_vout->p_sys->b_replace )
{
sprintf( psz_filename, "%s.%s", psz_prefix,
......
......@@ -137,10 +137,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return( 1 );
}
p_vout->p_sys->i_fd = open( "/dev/mga_vid", O_RDWR );
if( p_vout->p_sys->i_fd == -1 )
......
......@@ -153,10 +153,7 @@ static int OpenVideo( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
if( VLC_SUCCESS != Direct3DVoutCreate( p_vout ) )
......
......@@ -210,10 +210,7 @@ static int OpenVideo( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Initialisations */
......
......@@ -343,9 +343,12 @@ void EventThread( event_thread_t *p_event )
#ifdef UNICODE
{
wchar_t *psz_title = malloc( strlen(val.psz_string) * 2 + 2 );
mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
psz_title[strlen(val.psz_string)] = 0;
free( val.psz_string ); val.psz_string = (char *)psz_title;
if( psz_title )
{
mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
psz_title[strlen(val.psz_string)] = 0;
free( val.psz_string ); val.psz_string = (char *)psz_title;
}
}
#endif
......
......@@ -96,10 +96,7 @@ static int OpenVideo( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Initialisations */
......
......@@ -250,10 +250,7 @@ static int CreateVout( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
if( p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
var_Create( p_vout, "opengl-effect", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
......@@ -409,17 +406,11 @@ static int Init( vout_thread_t *p_vout )
p_sys->pp_buffer[0] =
malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
if( !p_sys->pp_buffer[0] )
{
msg_Err( p_vout, "out of memory" );
return -1;
}
p_sys->pp_buffer[1] =
malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
if( !p_sys->pp_buffer[1] )
{
msg_Err( p_vout, "out of memory" );
return -1;
}
p_vout->p_picture[0].i_planes = 1;
p_vout->p_picture[0].p->p_pixels = p_sys->pp_buffer[0];
......
......@@ -143,10 +143,7 @@ static int Open( vlc_object_t *p_this )
p_vout->p_sys = (struct vout_sys_t*) malloc( sizeof( struct vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return( 1 );
}
p_vout->pf_init = Init;
p_vout->pf_end = End;
......
......@@ -206,10 +206,7 @@ int Activate ( vlc_object_t *p_this )
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
}
vlc_mutex_init( &p_vout->p_sys->lock );
......@@ -2942,10 +2939,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
p_data = malloc( i_bytes_per_line * i_height );
#endif
if( !p_data )
{
msg_Err( p_vout, "out of memory" );
return NULL;
}
#ifdef MODULE_NAME_IS_x11
/* Optimize the quantum of a scanline regarding its size - the quantum is
......
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