]> git.sesse.net Git - vlc/commitdiff
VOBSUB: fixed memory leaks
authorAndrey Makhnutin <the.boobl@gmail.com>
Sun, 12 Jun 2011 14:08:38 +0000 (18:08 +0400)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 12 Jun 2011 14:20:46 +0000 (16:20 +0200)
Signed-off-by: Andrey Makhnutin <the.boobl@gmail.com>
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/vobsub.c

index 38b28718bff3ee1f82055a9c5bfd91f86c751a8c..d39d68512155c99bfa547c3ab6da5bf854139e51 100644 (file)
@@ -156,10 +156,7 @@ static int Open ( vlc_object_t *p_this )
     p_sys->i_tracks = 0;
     p_sys->track = malloc( sizeof( vobsub_track_t ) );
     if( unlikely( !p_sys->track ) )
-    {
-        free( p_sys );
-        return VLC_ENOMEM;
-    }
+        goto error;
     p_sys->i_original_frame_width = -1;
     p_sys->i_original_frame_height = -1;
     p_sys->b_palette = false;
@@ -190,10 +187,8 @@ static int Open ( vlc_object_t *p_this )
 
     if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access,
                   p_demux->psz_location ) == -1 )
-    {
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
+
     i_len = strlen( psz_vobname );
     if( i_len >= 4 ) memcpy( psz_vobname + i_len - 4, ".sub", 4 );
 
@@ -204,12 +199,20 @@ static int Open ( vlc_object_t *p_this )
         msg_Err( p_demux, "couldn't open .sub Vobsub file: %s",
                  psz_vobname );
         free( psz_vobname );
-        free( p_sys );
-        return VLC_EGENERIC;
+        goto error;
     }
     free( psz_vobname );
 
     return VLC_SUCCESS;
+
+error:
+    /* Clean all subs from all tracks */
+    for( int i = 0; i < p_sys->i_tracks; i++ )
+        free( p_sys->track[i].p_subtitles );
+    free( p_sys->track );
+    free( p_sys );
+
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************