vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Mon May 25 
21:41:27 2015 +0300| [b2a308560287256204786eecc4f4196370658bc4] | 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.

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

 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 56ebcc4..22cde78 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));
 

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to