]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/clone.c
Clone video filter : fix potential memleak.
[vlc] / modules / video_filter / clone.c
index b6d48320544b72263db46a90890b117fbd47e93a..4653563024b22e693a08f8166fb17f9b4855e601 100644 (file)
@@ -160,7 +160,7 @@ static int Create( vlc_object_t *p_this )
                                                 * sizeof(char *) );
         if( !p_vout->p_sys->ppsz_vout_list )
         {
-            msg_Err( p_vout, "out of memory" );
+            free( psz_clonelist );
             free( p_vout->p_sys );
             return VLC_ENOMEM;
         }
@@ -285,12 +285,16 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    RemoveAllVout( p_vout );
 }
 
 /*****************************************************************************
@@ -302,10 +306,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    RemoveAllVout( p_vout );
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys->pp_vout );
     free( p_vout->p_sys );
 }
@@ -328,7 +328,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
             vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ], 0, 0, 0 )
                ) == NULL )
         {
-            if( p_vout->b_die || p_vout->b_error )
+            if( !vlc_object_alive (p_vout) || p_vout->b_error )
             {
                 vout_DestroyPicture(
                     p_vout->p_sys->pp_vout[ i_vout ], p_outpic );
@@ -387,8 +387,7 @@ static void RemoveAllVout( vout_thread_t *p_vout )
          --p_vout->p_sys->i_clones;
          DEL_CALLBACKS( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones],
                         SendEvents );
-         vlc_object_detach( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
-         vlc_object_release( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
+         vout_CloseAndRelease( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
     }
 }