330b961
commit a5bd2e10e0c25b80286dc36068e22a4cb4893af0
330b961
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
330b961
Date:   Tue Aug 3 21:11:03 2021 +0530
330b961
330b961
    gaiconf_init: Avoid double-free in label and precedence lists
330b961
    
330b961
    labellist and precedencelist could get freed a second time if there
330b961
    are allocation failures, so set them to NULL to avoid a double-free.
330b961
    
330b961
    Reviewed-by: Arjun Shankar <arjun@redhat.com>
330b961
    (cherry picked from commit 77a34079d8f3d63b61543bf3af93043f8674e4c4)
330b961
330b961
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
330b961
index 838a68f0229b5aa8..43dfc6739e350a58 100644
330b961
--- a/sysdeps/posix/getaddrinfo.c
330b961
+++ b/sysdeps/posix/getaddrinfo.c
330b961
@@ -2008,6 +2008,7 @@ gaiconf_init (void)
330b961
 	      l = l->next;
330b961
 	    }
330b961
 	  free_prefixlist (labellist);
330b961
+	  labellist = NULL;
330b961
 
330b961
 	  /* Sort the entries so that the most specific ones are at
330b961
 	     the beginning.  */
330b961
@@ -2046,6 +2047,7 @@ gaiconf_init (void)
330b961
 	      l = l->next;
330b961
 	    }
330b961
 	  free_prefixlist (precedencelist);
330b961
+	  precedencelist = NULL;
330b961
 
330b961
 	  /* Sort the entries so that the most specific ones are at
330b961
 	     the beginning.  */