avahi: Fix leaking AvahiServiceResolver in the error paths
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Sat, 19 Jan 2019 21:41:12 +0000 (22:41 +0100)
committerSebastian Ramacher <sramacher@debian.org>
Thu, 27 Feb 2020 20:44:49 +0000 (20:44 +0000)
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
(cherry picked from commit 6d4afd268bbbf5c99609bd777d740a624cf7d705)
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
Gbp-Pq: Name 0004-avahi-Fix-leaking-AvahiServiceResolver-in-the-error-.patch

modules/services_discovery/avahi.c

index f1d4d06fe94e066d07d1787ce049d2a895a6b955..e73c44bf913fcfb8e2ac5d8ecb6608d66092ba9b 100644 (file)
@@ -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;
             }
         }