[vlc-devel] commit: Check malloc return value. (Jean-Paul Saman )

git version control git at videolan.org
Mon Oct 27 16:23:31 CET 2008


vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Fri Oct 24 13:46:18 2008 +0200| [28c2d3cff2eca6dab670d3a99c6f5889e5a7140a] | committer: Jean-Paul Saman 

Check malloc return value.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=28c2d3cff2eca6dab670d3a99c6f5889e5a7140a
---

 modules/access/file.c     |   14 +++++++++++++-
 modules/access/mms/mmsh.c |    4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index 5d7225f..0da4a38 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -2,7 +2,7 @@
  * file.c: file input (file: access plug-in)
  *****************************************************************************
  * Copyright (C) 2001-2006 the VideoLAN team
- * $Id$
+ * $Id: 5d7225fc8f4e85bc4e57849be0223bce47b7a31b $
  *
  * Authors: Christophe Massiot <massiot at via.ecp.fr>
  *          Rémi Denis-Courmont <rem # videolan # org>
@@ -203,6 +203,11 @@ static int Open( vlc_object_t *p_this )
     p_access->info.i_title = 0;
     p_access->info.i_seekpoint = 0;
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+    if( !p_sys )
+    {
+        free( psz_name );
+        return VLC_ENOMEM;
+    }
     p_sys->i_nb_reads = 0;
     p_sys->b_kfir = VLC_FALSE;
     p_sys->file = NULL;
@@ -258,6 +263,7 @@ static int Open( vlc_object_t *p_this )
         {
             msg_Err( p_access, "unknown file type for `%s'", psz_name );
             free( psz_name );
+            free( p_sys );
             return VLC_EGENERIC;
         }
     }
@@ -291,6 +297,12 @@ static int Open( vlc_object_t *p_this )
      * Get the additional list of files
      */
     p_file = malloc( sizeof(file_entry_t) );
+    if( !p_file )
+    {
+        free( psz_name );
+        free( p_sys );
+        return VLC_ENOMEM;
+    }
     p_file->i_size = p_access->info.i_size;
     p_file->psz_name = psz_name;
     TAB_APPEND( p_sys->i_file, p_sys->file, p_file );
diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c
index 4d32bd1..4d34eec 100644
--- a/modules/access/mms/mmsh.c
+++ b/modules/access/mms/mmsh.c
@@ -2,7 +2,7 @@
  * mmsh.c:
  *****************************************************************************
  * Copyright (C) 2001, 2002 the VideoLAN team
- * $Id$
+ * $Id: 4d32bd1f88d01e0b157b8a4dd5de4f5c5ce51379 $
  *
  * Authors: Laurent Aimar <fenrir at via.ecp.fr>
  *
@@ -82,6 +82,8 @@ int E_(MMSHOpen)( access_t *p_access )
     p_access->info.i_title = 0;
     p_access->info.i_seekpoint = 0;
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
     memset( p_sys, 0, sizeof( access_sys_t ) );
     p_sys->i_proto= MMS_PROTO_HTTP;
     p_sys->fd     = -1;




More information about the vlc-devel mailing list