[vlc-devel] commit: Fix a segfault if the mask can' t be loaded and aso fail imediately if the file ( Rémi Duraffort )

git version control git at videolan.org
Tue Jun 30 16:39:10 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Jun 30 16:31:32 2009 +0200| [77190676767ff54dab9c39a97bf17c57a80ca576] | committer: Rémi Duraffort 

Fix a segfault if the mask can't be loaded and aso fail imediately if the file
does not exist.

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

 modules/video_filter/erase.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/video_filter/erase.c b/modules/video_filter/erase.c
index c129731..2cbe6c6 100644
--- a/modules/video_filter/erase.c
+++ b/modules/video_filter/erase.c
@@ -113,6 +113,9 @@ static void LoadMask( filter_t *p_filter, const char *psz_filename )
         p_filter->p_sys->p_mask = p_old_mask;
         msg_Err( p_filter, "Error while loading new mask. Keeping old mask." );
     }
+    else
+        msg_Err( p_filter, "Error while loading new mask. No mask available." );
+
     image_HandlerDelete( p_image );
 }
 
@@ -199,18 +202,29 @@ static void Destroy( vlc_object_t *p_this )
 static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 {
     picture_t *p_outpic;
+    filter_sys_t *p_sys = p_filter->p_sys;
 
     if( !p_pic ) return NULL;
 
+    /* If the mask if empty return the picture */
+    vlc_mutex_lock( &p_sys->lock );
+    if( !p_sys->p_mask )
+    {
+        vlc_mutex_unlock( &p_sys->lock );
+        return p_pic;
+    }
+
     p_outpic = filter_NewPicture( p_filter );
     if( !p_outpic )
     {
         picture_Release( p_pic );
+        vlc_mutex_unlock( &p_sys->lock );
         return NULL;
     }
 
     /* Here */
     FilterErase( p_filter, p_pic, p_outpic );
+    vlc_mutex_unlock( &p_sys->lock );
 
     return CopyInfoAndRelease( p_outpic, p_pic );
 }
@@ -223,7 +237,6 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    vlc_mutex_lock( &p_sys->lock );
     const int i_mask_pitch = p_sys->p_mask->A_PITCH;
     const int i_mask_visible_pitch = p_sys->p_mask->p[A_PLANE].i_visible_pitch;
     const int i_mask_visible_lines = p_sys->p_mask->p[A_PLANE].i_visible_lines;
@@ -392,7 +405,6 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
             }
         }
     }
-    vlc_mutex_unlock( &p_sys->lock );
 }
 
 static int EraseCallback( vlc_object_t *p_this, char const *psz_var,




More information about the vlc-devel mailing list