[vlc-commits] upnp: Fix potential leak on error

Hugo Beauzée-Luyssen git at videolan.org
Wed Jan 18 16:01:30 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Jan 18 14:43:22 2017 +0100| [3dfd02234c62f3d00713404090230b53e352b594] | committer: Hugo Beauzée-Luyssen

upnp: Fix potential leak on error

Fix CID #1372938

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

 modules/services_discovery/upnp.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index a802eed..98afcf8 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -1334,7 +1334,10 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
     {
         UpnpInstanceWrapper* instance = new(std::nothrow) UpnpInstanceWrapper;
         if ( unlikely( !instance ) )
+        {
+            delete p_server_list;
             return NULL;
+        }
 
     #ifdef UPNP_ENABLE_IPV6
         char* psz_miface = var_InheritString( p_obj, "miface" );
@@ -1349,6 +1352,7 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
         {
             msg_Err( p_obj, "Initialization failed: %s", UpnpGetErrorMessage( i_res ) );
             delete instance;
+            delete p_server_list;
             return NULL;
         }
 
@@ -1360,6 +1364,7 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
         {
             msg_Err( p_obj, "Client registration failed: %s", UpnpGetErrorMessage( i_res ) );
             delete instance;
+            delete p_server_list;
             return NULL;
         }
 
@@ -1371,6 +1376,7 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, services_disc
             msg_Err( p_obj, "Failed to set maximum content length: %s",
                     UpnpGetErrorMessage( i_res ));
             delete instance;
+            delete p_server_list;
             return NULL;
         }
         s_instance = instance;



More information about the vlc-commits mailing list