[vlc-commits] objects: fix race in ObjectKillChildren() (fixes #13979)

Rémi Denis-Courmont git at videolan.org
Mon May 25 20:44:25 CEST 2015


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 25 21:41:27 2015 +0300| [5fb4742d4750d0c390250de69f8076e47998877e] | committer: Rémi Denis-Courmont

objects: fix race in ObjectKillChildren() (fixes #13979)

If an object is created after the parent is already killed,
ObjectKillChildren() could not have killed the new object. So the new
object needs to inherit the alive flag from its parent instead.

(cherry picked from commit b2a308560287256204786eecc4f4196370658bc4)

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

 src/misc/objects.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 0026ea8..3bef2c2 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -133,7 +133,6 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
     vlc_mutex_init (&priv->var_lock);
     vlc_cond_init (&priv->var_wait);
     priv->pipes[0] = priv->pipes[1] = -1;
-    atomic_init (&priv->alive, true);
     atomic_init (&priv->refs, 1);
     priv->pf_destructor = NULL;
     priv->prev = NULL;
@@ -157,6 +156,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
 
         /* Attach the parent to its child (structure lock needed) */
         libvlc_lock (obj->p_libvlc);
+        atomic_init (&priv->alive, atomic_load (&papriv->alive));
         priv->next = papriv->first;
         if (priv->next != NULL)
             priv->next->prev = priv;
@@ -170,6 +170,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
         obj->i_flags = 0;
         obj->p_libvlc = self;
         obj->p_parent = NULL;
+        atomic_init (&priv->alive, true);
         priv->next = NULL;
         vlc_mutex_init (&(libvlc_priv (self)->structure_lock));
 



More information about the vlc-commits mailing list