[vlc-commits] access: bluray: check for overlay pointer overwrite

Francois Cartegnie git at videolan.org
Mon Mar 9 10:40:41 CET 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar  6 17:02:46 2020 +0100| [5c3b3c1cff3143174bce9dfdd5c142cc3b081ee1] | committer: Francois Cartegnie

access: bluray: check for overlay pointer overwrite

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

 modules/access/bluray.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 8c6f2859b5..3d20b53e64 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -1840,25 +1840,6 @@ static void blurayActivateOverlay(demux_t *p_demux, int plane)
     vlc_mutex_unlock(&ov->lock);
 }
 
-static void blurayInitOverlay(demux_t *p_demux, int plane, int width, int height)
-{
-    demux_sys_t *p_sys = p_demux->p_sys;
-
-    assert(p_sys->bdj.p_overlays[plane] == NULL);
-
-    bluray_overlay_t *ov = calloc(1, sizeof(*ov));
-    if (unlikely(ov == NULL))
-        return;
-
-    ov->width = width;
-    ov->height = height;
-    ov->b_on_vout = false;
-
-    vlc_mutex_init(&ov->lock);
-
-    p_sys->bdj.p_overlays[plane] = ov;
-}
-
 /**
  * Destroy every regions in the subpicture.
  * This is done in two steps:
@@ -1884,6 +1865,31 @@ static void blurayClearOverlay(demux_t *p_demux, int plane)
     vlc_mutex_unlock(&ov->lock);
 }
 
+static void blurayInitOverlay(demux_t *p_demux, int plane, int width, int height)
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    if(p_sys->bdj.p_overlays[plane])
+    {
+        /* Should not happen */
+        msg_Warn( p_demux, "Trying to init over an existing overlay" );
+        blurayClearOverlay( p_demux, plane );
+        blurayCloseOverlay( p_demux, plane );
+    }
+
+    bluray_overlay_t *ov = calloc(1, sizeof(*ov));
+    if (unlikely(ov == NULL))
+        return;
+
+    ov->width = width;
+    ov->height = height;
+    ov->b_on_vout = false;
+
+    vlc_mutex_init(&ov->lock);
+
+    p_sys->bdj.p_overlays[plane] = ov;
+}
+
 /*
  * This will draw to the overlay by adding a region to our region list
  * This will have to be copied to the subpicture used to render the overlay.



More information about the vlc-commits mailing list