[vlc-commits] cdda: memory leak due to STANDARD_BLOCK_ACCESS_INIT

Rémi Denis-Courmont git at videolan.org
Mon Nov 17 18:03:26 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Nov 17 18:45:52 2014 +0200| [b306cb2d3056b0240f6597dda4d19c6febde3f93] | committer: Rémi Denis-Courmont

cdda: memory leak due to STANDARD_BLOCK_ACCESS_INIT

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

 modules/access/cdda.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index c93995b..5d31a7d 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -127,7 +127,6 @@ static cddb_disc_t *GetCDDBInfo( access_t *p_access, int i_titles, int *p_sector
 static int Open( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t*)p_this;
-    access_sys_t *p_sys;
     vcddev_t     *vcddev;
     char         *psz_name;
 
@@ -147,18 +146,26 @@ static int Open( vlc_object_t *p_this )
     if( psz_name[0] && psz_name[1] == ':' &&
         psz_name[2] == '\\' && psz_name[3] == '\0' ) psz_name[2] = '\0';
 #endif
-    /* Set up p_access */
-    STANDARD_BLOCK_ACCESS_INIT
 
-    /* Open CDDA */
-    if( (vcddev = ioctl_Open( VLC_OBJECT(p_access), psz_name ) ) == NULL )
+    access_sys_t *p_sys = calloc( 1, sizeof (*p_sys) );
+    if( unlikely(p_sys == NULL) )
     {
-        msg_Warn( p_access, "could not open %s", psz_name );
         free( psz_name );
+        return VLC_ENOMEM;
+    }
+    p_access->p_sys = p_sys;
+
+    /* Open CDDA */
+    vcddev = ioctl_Open( VLC_OBJECT(p_access), psz_name );
+    if( vcddev == NULL )
+        msg_Warn( p_access, "could not open %s", psz_name );
+    free( psz_name );
+    if( vcddev == NULL )
+    {
         free( p_sys );
         return VLC_EGENERIC;
     }
-    free( psz_name );
+
     p_sys->vcddev = vcddev;
 
     /* Do we play a single track ? */
@@ -224,6 +231,9 @@ static int Open( vlc_object_t *p_this )
                                      * (int64_t)CDDA_DATA_SIZE;
     }
 
+    /* Set up p_access */
+    access_InitFields( p_access );
+    ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek );
     return VLC_SUCCESS;
 
 error:



More information about the vlc-commits mailing list