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

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Aug 6 15:25:42 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/services_discovery/upnp-wrapper.cpp b/modules/services_discovery/upnp-wrapper.cpp
index c001492f37..76ceb89a1b 100644
--- a/modules/services_discovery/upnp-wrapper.cpp
+++ b/modules/services_discovery/upnp-wrapper.cpp
@@ -119,8 +119,8 @@ void UpnpInstanceWrapper::release()
         p_delete = s_instance;
         s_instance = NULL;
     }
-    vlc_mutex_unlock( &s_lock );
     delete p_delete;
+    vlc_mutex_unlock( &s_lock );
 }
 
 UpnpClient_Handle UpnpInstanceWrapper::handle() const
-- 
2.20.1



More information about the vlc-devel mailing list