]> git.sesse.net Git - vlc/commitdiff
bluray: blurayInitTitles: fix memleaks on error paths
authorRafaël Carré <funman@videolan.org>
Mon, 12 Aug 2013 07:39:12 +0000 (09:39 +0200)
committerRafaël Carré <funman@videolan.org>
Fri, 16 Aug 2013 10:43:13 +0000 (12:43 +0200)
modules/access/bluray.c

index f0b147e07286ae30e766fb78ecec86e5e3c2bdb0..f5978c437f67c4b92051c88921511f04414a25b9 100644 (file)
@@ -1026,23 +1026,30 @@ static void blurayInitTitles(demux_t *p_demux )
             break;
 
         BLURAY_TITLE_INFO *title_info = bd_get_title_info(p_sys->bluray, i, 0);
-        if (!title_info)
+        if (!title_info) {
+            vlc_input_title_Delete(t);
             break;
-        t->i_length = FROM_TICKS(title_info->duration);
-
-        if (t->i_length > duration) {
-            duration = t->i_length;
-            p_sys->i_longest_title = i;
         }
 
+        t->i_length = FROM_TICKS(title_info->duration);
+
         for ( unsigned int j = 0; j < title_info->chapter_count; j++) {
             seekpoint_t *s = vlc_seekpoint_New();
-            if (!s)
+            if (!s) {
+                bd_free_title_info(title_info);
+                vlc_input_title_Delete(t);
                 break;
+            }
             s->i_time_offset = title_info->chapters[j].offset;
 
             TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
         }
+
+        if (t->i_length > duration) {
+            duration = t->i_length;
+            p_sys->i_longest_title = i;
+        }
+
         TAB_APPEND( p_sys->i_title, p_sys->pp_title, t );
         bd_free_title_info(title_info);
     }