[vlc-commits] avahi: Fix leaking AvahiServiceResolver in the error paths

Stefan Brüns git at videolan.org
Thu Feb 27 14:10:35 CET 2020


vlc/vlc-3.0 | branch: master | Stefan Brüns <stefan.bruens at rwth-aachen.de> | Sat Jan 19 22:41:12 2019 +0100| [edbdd45c0dd7a913ec1fe7956c9a7e1cf498ed63] | committer: Thomas Guillem

avahi: Fix leaking AvahiServiceResolver in the error paths

Signed-off-by: Thomas Guillem <thomas at gllm.fr>
(cherry picked from commit 6d4afd268bbbf5c99609bd777d740a624cf7d705)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/services_discovery/avahi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/services_discovery/avahi.c b/modules/services_discovery/avahi.c
index f1d4d06fe9..e73c44bf91 100644
--- a/modules/services_discovery/avahi.c
+++ b/modules/services_discovery/avahi.c
@@ -148,7 +148,10 @@ static void resolve_callback(
         avahi_address_snprint(a, (sizeof(a)/sizeof(a[0]))-1, address);
         if( protocol == AVAHI_PROTO_INET6 )
             if( asprintf( &psz_addr, "[%s]", a ) == -1 )
+            {
+                avahi_service_resolver_free( r );
                 return;
+            }
 
         const char *psz_protocol = NULL;
         for( unsigned int i = 0; i < NB_PROTOCOLS; i++ )
@@ -157,7 +160,11 @@ static void resolve_callback(
                 psz_protocol = protocols[i].psz_protocol;
         }
         if( psz_protocol == NULL )
+        {
+            free( psz_addr );
+            avahi_service_resolver_free( r );
             return;
+        }
 
         if( txt != NULL )
             asl = avahi_string_list_find( txt, "path" );
@@ -175,6 +182,7 @@ static void resolve_callback(
                           port, value ) == -1 )
                 {
                     free( psz_addr );
+                    avahi_service_resolver_free( r );
                     return;
                 }
             }
@@ -190,6 +198,7 @@ static void resolve_callback(
                       psz_addr != NULL ? psz_addr : a, port ) == -1 )
             {
                 free( psz_addr );
+                avahi_service_resolver_free( r );
                 return;
             }
         }



More information about the vlc-commits mailing list