[vlc-devel] commit: postproc: fix potential crash ( var_DelCallback missing and callback added too ( Rémi Duraffort )
git version control
git at videolan.org
Fri Jun 26 10:32:27 CEST 2009
vlc | branch: 1.0-bugfix | Rémi Duraffort <ivoire at videolan.org> | Thu Jun 25 15:17:02 2009 +0200| [ff65a2c365c0e6a06d27ed15c22364c0f50ecdee] | committer: Rémi Duraffort
postproc: fix potential crash (var_DelCallback missing and callback added too
early).
(cherry picked from commit 36eb6ac98a883477beb9d82895716a8488c5f875)
Signed-off-by: Rémi Duraffort <ivoire at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ff65a2c365c0e6a06d27ed15c22364c0f50ecdee
---
modules/video_filter/postproc.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c
index 3aa05bc..08fc1c1 100644
--- a/modules/video_filter/postproc.c
+++ b/modules/video_filter/postproc.c
@@ -196,7 +196,6 @@ static int OpenPostproc( vlc_object_t *p_this )
/* For some obscure reason the VLC_VAR_ISCOMMAND isn't taken into account
in during var_Create */
var_Change( p_filter, FILTER_PREFIX "q", VLC_VAR_SETISCOMMAND, NULL, NULL );
- var_AddCallback( p_filter, FILTER_PREFIX "q", PPQCallback, NULL );
text.psz_string = _("Post processing");
var_Change( p_filter, FILTER_PREFIX "q", VLC_VAR_SETTEXT, &text, NULL );
@@ -206,7 +205,6 @@ static int OpenPostproc( vlc_object_t *p_this )
val.psz_string = var_CreateGetNonEmptyStringCommand(
p_filter, FILTER_PREFIX "name" );
- var_AddCallback( p_filter, FILTER_PREFIX "name", PPNameCallback, NULL );
if( val_orig.i_int )
{
p_sys->pp_mode = pp_get_mode_by_name_and_quality( val.psz_string ?
@@ -251,7 +249,11 @@ static int OpenPostproc( vlc_object_t *p_this )
&val, text.psz_string?&text:NULL );
}
- vlc_mutex_init( &p_sys->lock ); /* FIXME: too late w.r.t. callback */
+ vlc_mutex_init( &p_sys->lock );
+
+ /* Add the callback at the end to prevent crashes */
+ var_AddCallback( p_filter, FILTER_PREFIX "q", PPQCallback, NULL );
+ var_AddCallback( p_filter, FILTER_PREFIX "name", PPNameCallback, NULL );
p_filter->pf_video_filter = PostprocPict;
p_sys->b_had_matrix = true;
@@ -267,7 +269,11 @@ static void ClosePostproc( vlc_object_t *p_this )
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
- /* FIXME: delete callbacks before mutex */
+ /* delete the callback before destroying the mutex */
+ var_DelCallback( p_filter, FILTER_PREFIX "q", PPQCallback, NULL );
+ var_DelCallback( p_filter, FILTER_PREFIX "name", PPNameCallback, NULL );
+
+ /* Destroy the resources */
vlc_mutex_destroy( &p_sys->lock );
pp_free_context( p_sys->pp_context );
if( p_sys->pp_mode ) pp_free_mode( p_sys->pp_mode );
More information about the vlc-devel
mailing list