]> git.sesse.net Git - vlc/commitdiff
Check malloc return value when needed and don't print an error when such error happend.
authorRémi Duraffort <ivoire@videolan.org>
Thu, 22 May 2008 19:58:28 +0000 (21:58 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Thu, 22 May 2008 21:24:08 +0000 (23:24 +0200)
Fix a potential segfault.

16 files changed:
modules/video_output/aa.c
modules/video_output/caca.c
modules/video_output/directfb.c
modules/video_output/fb.c
modules/video_output/ggi.c
modules/video_output/glide.c
modules/video_output/hd1000v.cpp
modules/video_output/image.c
modules/video_output/mga.c
modules/video_output/msw/direct3d.c
modules/video_output/msw/directx.c
modules/video_output/msw/events.c
modules/video_output/msw/glwin32.c
modules/video_output/opengl.c
modules/video_output/qte/qte.cpp
modules/video_output/x11/xcommon.c

index 00b88f202f646a4337285c908b25a6a0c573eb43..92e663c76c8310ed6b1d6d0162afeabe14706461 100644 (file)
@@ -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 );
index 67a6743a63e64a63053437ee839eb45aa602608c..967dea8e68c0d9af94a6dee4247927186247715a 100644 (file)
@@ -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 )
index 512f2da6f6322f17624cac29fc281c1b0cbcb749..3b82eaf901657b0a31a5fde35d125451d9503491 100644 (file)
@@ -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;
index e34f3f373da09506b4bfacba12986dc7df3529d3..91b28ba0d10b212eb8fc3922be545845fbce9108 100644 (file)
@@ -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 );
 
index f7b682c1e7a194e2387e2f2bd2e2f0bf476a75eb..804e03a01a39ad5f617e40e3e5a865c04ae154d3 100644 (file)
@@ -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 ) )
index d70479e8096fc80c68217f0d8578fc86b70e6c02..2c8c425f30f9735ed8e10803248939ffd3618e5d 100644 (file)
@@ -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 ) )
index 51f62cad4aa742677b46ad068e2e5bff6db05929..34a0213e66573b551208b92f6409faf2720ebd03 100644 (file)
@@ -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();
index 215ab24ca546b26623121dac4c23d20b04c27f26..4225b987001634f48f2e093f1231410022526283 100644 (file)
@@ -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,
index fc8f88daf1145fc6d1daacec3265f16bc4f54038..a9f53d9cdcc2fb0a97cf789c200fafb1a4db1f5a 100644 (file)
@@ -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 )
index 85b0754c6b02bb0fc0fa0c0ebe8e4f0c1359db88..19c8efc133c4a03bfd5c4f000f910279db567d56 100644 (file)
@@ -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 ) )
index 552db7d8033e5f64e9a4ccb999a4bd31e57d8f5c..ec72dcd1342780750fd95a38feb32b32aff47530 100644 (file)
@@ -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 */
index 2245bd6de18572312f20a4bdafd1186640475956..f37d9520be4b8db5b30c7375b7d23fdae58356d4 100644 (file)
@@ -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
 
index 3258e76d6f1f5b77645e579ad079db4444a6ebd1..b4db014b22ebe3c8c10881d01560db109bb64aef 100644 (file)
@@ -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 */
index 504ae30cd9a3c52ee1b8832d3559d84f80fe71ee..13666f9b381b1831e86c0348543e6f98147fab75 100644 (file)
@@ -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];
index 9912f6026b91936c71b275cd8fd9daa0764cea14..da41e4a4798977c57bfe25d02e88be6cc944bb76 100644 (file)
@@ -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;
index 3560352414ce85b9ecc78ccfd3e9b59d3c45bc09..be72fc9bb0620f86f8939267d09d07a9aa1d7669 100644 (file)
@@ -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