[vlc-commits] Zip: check memory allocations or fail (in Open)

Jean-Philippe André git at videolan.org
Fri Jan 21 19:10:18 CET 2011


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Fri Jan 21 18:00:45 2011 +0100| [d479ed1b7e8542cfc7ad00cfa4df19a1b7a5da33] | committer: Jean-Philippe André

Zip: check memory allocations or fail (in Open)

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

 modules/access/zip/zipaccess.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/modules/access/zip/zipaccess.c b/modules/access/zip/zipaccess.c
index ad4bc99..1611e78 100644
--- a/modules/access/zip/zipaccess.c
+++ b/modules/access/zip/zipaccess.c
@@ -128,16 +128,31 @@ int AccessOpen( vlc_object_t *p_this )
         msg_Dbg( p_access, "not an encoded URL  Trying file '%s'",
                  psz_path );
         psz_pathToZip = strdup( psz_path );
+        if( !psz_pathToZip )
+        {
+            i_ret = VLC_ENOMEM;
+            goto exit;
+        }
     }
     p_sys->psz_fileInzip = unescapeXml( psz_sep + ZIP_SEP_LEN );
     if( !p_sys->psz_fileInzip )
     {
         p_sys->psz_fileInzip = strdup( psz_sep + ZIP_SEP_LEN );
+        if( !p_sys->psz_fileInzip )
+        {
+            i_ret = VLC_ENOMEM;
+            goto exit;
+        }
     }
 
     /* Define IO functions */
     zlib_filefunc_def *p_func = (zlib_filefunc_def*)
                                     calloc( 1, sizeof( zlib_filefunc_def ) );
+    if( !p_func )
+    {
+        i_ret = VLC_ENOMEM;
+        goto exit;
+    }
     p_func->zopen_file   = ZipIO_Open;
     p_func->zread_file   = ZipIO_Read;
     p_func->zwrite_file  = ZipIO_Write; // see comment
@@ -375,7 +390,8 @@ static void* ZCALLBACK ZipIO_Open( void* opaque, const char* file, int mode )
     access_t *p_access = (access_t*) opaque;
 
     char *fileUri = malloc( strlen(file) + 8 );
-    if( !fileUri ) return VLC_ENOMEM;
+    if( !fileUri )
+        return NULL;
     if( !strstr( file, "://" ) )
     {
         strcpy( fileUri, "file://" );



More information about the vlc-commits mailing list