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

Francois Cartegnie git at videolan.org
Mon Mar 9 10:48:08 CET 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar  6 17:02:46 2020 +0100| [24f264abf3db72a2500c1c00bf9a8e4f7a799bf9] | committer: Francois Cartegnie

access: bluray: check for overlay pointer overwrite

(cherry picked from commit 5c3b3c1cff3143174bce9dfdd5c142cc3b081ee1)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=24f264abf3db72a2500c1c00bf9a8e4f7a799bf9
---

 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 0f3f1d4be2..7defd6234f 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -1677,25 +1677,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->p_overlays[plane] == NULL);
-
-    bluray_overlay_t *ov = calloc(1, sizeof(*ov));
-    if (unlikely(ov == NULL))
-        return;
-
-    ov->width = width;
-    ov->height = height;
-    ov->i_channel = -1;
-
-    vlc_mutex_init(&ov->lock);
-
-    p_sys->p_overlays[plane] = ov;
-}
-
 /**
  * Destroy every regions in the subpicture.
  * This is done in two steps:
@@ -1721,6 +1702,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->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->i_channel = -1;
+
+    vlc_mutex_init(&ov->lock);
+
+    p_sys->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