[vlc-devel] [PATCH] upnp: Fix potential race during tear down.
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Aug 7 16:47:33 CEST 2019
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
---
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;
}
--
2.20.1
More information about the vlc-devel
mailing list