[vlc-commits] upnp: do not delete the UpnpInstanceWrapper instance under s_lock

Steve Lhomme git at videolan.org
Sun Jun 5 14:35:13 CEST 2016


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Jun  2 14:08:19 2016 +0200| [17ca1cbf2511728ed4f45ba2d21cec827d500441] | committer: Thomas Guillem

upnp: do not delete the UpnpInstanceWrapper instance under s_lock

It calls UpnpFinish() which might wait for some callbacks to finish and they
may be locked with s_lock.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/services_discovery/upnp.cpp |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 09d94fc..3ea5bde 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -1298,7 +1298,8 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
 
 void UpnpInstanceWrapper::release(bool isSd)
 {
-    vlc_mutex_locker lock( &s_lock );
+    UpnpInstanceWrapper *p_delete = NULL;
+    vlc_mutex_lock( &s_lock );
     if ( isSd )
     {
         delete UpnpInstanceWrapper::p_server_list;
@@ -1306,9 +1307,11 @@ void UpnpInstanceWrapper::release(bool isSd)
     }
     if (--s_instance->m_refcount == 0)
     {
-        delete s_instance;
+        p_delete = s_instance;
         s_instance = NULL;
     }
+    vlc_mutex_unlock( &s_lock );
+    delete p_delete;
 }
 
 UpnpClient_Handle UpnpInstanceWrapper::handle() const



More information about the vlc-commits mailing list