[vlc-commits] vout: delete interface callbacks explicitly

Rémi Denis-Courmont git at videolan.org
Sun Jan 27 22:10:20 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 27 22:44:02 2019 +0200| [6ae5ceb38cef7b579e511d0894b64d612820e7b0] | committer: Rémi Denis-Courmont

vout: delete interface callbacks explicitly

Once the callbacks are deleted, we are assured that they will no longer
be triggered. Then we can safely destroy resources without the risk of
causing use-after-free if a user interface sets a variable.

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

 src/video_output/video_output.c  |  2 ++
 src/video_output/vout_internal.h |  1 +
 src/video_output/vout_intf.c     | 21 +++++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 229bc70cff..1a8829efdb 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1609,6 +1609,8 @@ void vout_Close(vout_thread_t *vout)
 {
     assert(vout);
 
+    vout_IntfDeinit(VLC_OBJECT(vout));
+
     spu_Detach(vout->p->spu);
     vout_snapshot_End(vout->p->snapshot);
 
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 71968a3c7e..e7143dfc62 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -231,6 +231,7 @@ void vout_ControlChangeViewpoint( vout_thread_t *, const vlc_viewpoint_t *);
 /* */
 void vout_IntfInit( vout_thread_t * );
 void vout_IntfReinit( vout_thread_t * );
+void vout_IntfDeinit(vlc_object_t *);
 
 /* */
 int vout_OpenWrapper(vout_thread_t *, const char *,
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 3b7076d99f..7008cf69bd 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -311,6 +311,27 @@ void vout_IntfReinit( vout_thread_t *p_vout )
     var_TriggerCallback( p_vout, "sub-margin" );
 }
 
+void vout_IntfDeinit(vlc_object_t *obj)
+{
+    var_DelCallback(obj, "viewpoint", ViewpointCallback, NULL);
+    var_DelCallback(obj, "sub-margin", SubMarginCallback, NULL);
+    var_DelCallback(obj, "sub-filter", SubFilterCallback, NULL);
+    var_DelCallback(obj, "sub-source", SubSourceCallback, NULL);
+    var_DelCallback(obj, "video-filter", VideoFilterCallback, NULL);
+    var_DelCallback(obj, "video-snapshot", SnapshotCallback, NULL);
+    var_DelCallback(obj, "fullscreen", FullscreenCallback, NULL);
+    var_DelCallback(obj, "video-wallpaper", WallPaperCallback, NULL);
+    var_DelCallback(obj, "video-on-top", AboveCallback, NULL);
+    var_DelCallback(obj, "aspect-ratio", AspectCallback, NULL);
+    var_DelCallback(obj, "crop", CropCallback, NULL);
+    var_DelCallback(obj, "crop-bottom", CropBorderCallback, NULL);
+    var_DelCallback(obj, "crop-right", CropBorderCallback, NULL);
+    var_DelCallback(obj, "crop-top", CropBorderCallback, NULL);
+    var_DelCallback(obj, "crop-left", CropBorderCallback, NULL);
+    var_DelCallback(obj, "zoom", ZoomCallback, NULL);
+    var_DelCallback(obj, "autoscale", AutoScaleCallback, NULL);
+}
+
 /*****************************************************************************
  * vout_Snapshot: generates a snapshot.
  *****************************************************************************/



More information about the vlc-commits mailing list