[vlc-commits] cycle: fix double free

Rémi Denis-Courmont git at videolan.org
Mon Oct 12 17:04:22 CEST 2020


vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 11 21:29:04 2020 +0300| [cfcc4be2c44e682f641ec675b8ea03081e113a01] | committer: Rémi Denis-Courmont

cycle: fix double free

See also c1c40b2ac6788c3e0e37333e3935ffd10711650f.

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

 modules/stream_out/cycle.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/modules/stream_out/cycle.c b/modules/stream_out/cycle.c
index bb031f81ae..80cf2b471e 100644
--- a/modules/stream_out/cycle.c
+++ b/modules/stream_out/cycle.c
@@ -56,6 +56,7 @@ struct sout_stream_id_sys_t
 struct sout_stream_sys_t
 {
     sout_stream_t *stream; /*< Current output stream */
+    sout_stream_t *last_stream;
     sout_stream_id_sys_t *first; /*< First elementary stream */
     sout_stream_id_sys_t *last; /*< Last elementary stream */
 
@@ -126,7 +127,7 @@ static int AddStream(sout_stream_t *stream, char *chain)
     msg_Dbg(stream, "starting new phase \"%s\"", chain);
     /* TODO format */
     sys->stream = sout_StreamChainNew(stream->p_sout, chain,
-                                      stream->p_next, NULL);
+                                      stream->p_next, &sys->last_stream);
     if (sys->stream == NULL)
         return -1;
 
@@ -147,7 +148,7 @@ static void DelStream(sout_stream_t *stream)
         if (id->id != NULL)
             sout_StreamIdDel(sys->stream, id->id);
 
-    sout_StreamChainDelete(sys->stream, NULL);
+    sout_StreamChainDelete(sys->stream, sys->last_stream);
     sys->stream = NULL;
 }
 
@@ -310,7 +311,7 @@ static void Close(vlc_object_t *obj)
     assert(sys->first == NULL && sys->last == NULL);
 
     if (sys->stream != NULL)
-        sout_StreamChainDelete(sys->stream, NULL);
+        sout_StreamChainDelete(sys->stream, sys->last_stream);
 
     for (sout_cycle_t *cycle = sys->start, *next; cycle != NULL; cycle = next)
     {



More information about the vlc-commits mailing list