[vlc-devel] commit: Handle libass track creation errors. (Laurent Aimar )

git version control git at videolan.org
Sat Aug 9 02:21:04 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Aug  5 00:31:33 2008 +0200| [9c537633ba83abf6db6d5b83dc59d447d90cb4dd] | committer: Laurent Aimar 

Handle libass track creation errors.

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

 modules/codec/libass.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index 90a0dc5..1771ad4 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -140,11 +140,15 @@ static int Create( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     /* */
+    p_sys->p_ass = AssHandleYield( p_dec );
+    if( !p_sys->p_ass )
+    {
+        free( p_sys );
+        return VLC_EGENERIC;
+    }
     vlc_mutex_init( &p_sys->lock );
     p_sys->i_refcount = 1;
 
-    p_sys->p_ass = AssHandleYield( p_dec );
-
     /* load attachments */
     input_attachment_t  **pp_attachments;
     int                   i_attachments;
@@ -173,6 +177,12 @@ static int Create( vlc_object_t *p_this )
     /* Add a track */
     vlc_mutex_lock( p_sys->p_ass->p_lock );
     p_sys->p_track = p_track = ass_new_track( p_sys->p_ass->p_library );
+    if( !p_track )
+    {
+        vlc_mutex_unlock( p_sys->p_ass->p_lock );
+        DecSysRelease( p_sys );
+        return VLC_EGENERIC;
+    }
     ass_process_codec_private( p_track, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
     vlc_mutex_unlock( p_sys->p_ass->p_lock );
 
@@ -209,7 +219,8 @@ static void DecSysRelease( decoder_sys_t *p_sys )
     vlc_mutex_destroy( &p_sys->lock );
 
     vlc_mutex_lock( p_sys->p_ass->p_lock );
-    ass_free_track( p_sys->p_track );
+    if( p_sys->p_track )
+        ass_free_track( p_sys->p_track );
     vlc_mutex_unlock( p_sys->p_ass->p_lock );
 
     AssHandleRelease( p_sys->p_ass );




More information about the vlc-devel mailing list