[vlc-commits] upnp: Fix potential race during tear down.

Hugo Beauzée-Luyssen git at videolan.org
Thu Aug 8 11:50:22 CEST 2019


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Aug  6 15:24:26 2019 +0200| [2873288c7c7b1f62f67ce41b1928b326019f7898] | committer: Hugo Beauzée-Luyssen

upnp: Fix potential race during tear down.

If two threads call UpnpFinish at the same time (or more precisely, if a
2nd thread calls UpnpFinish before the first one sets UpnpSdkInit to 0)
we can end up double releasing most libupnp resources

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

 modules/services_discovery/upnp-wrapper.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/services_discovery/upnp-wrapper.cpp b/modules/services_discovery/upnp-wrapper.cpp
index c001492f37..3b8037b3f1 100644
--- a/modules/services_discovery/upnp-wrapper.cpp
+++ b/modules/services_discovery/upnp-wrapper.cpp
@@ -113,13 +113,12 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj)
 void UpnpInstanceWrapper::release()
 {
     UpnpInstanceWrapper *p_delete = NULL;
-    vlc_mutex_lock( &s_lock );
+    vlc::threads::mutex_locker lock( &s_lock );
     if (--s_instance->m_refcount == 0)
     {
         p_delete = s_instance;
         s_instance = NULL;
     }
-    vlc_mutex_unlock( &s_lock );
     delete p_delete;
 }
 



More information about the vlc-commits mailing list