Blame SOURCES/glibc-rh1451308.patch

147e83
commit d62aa75af1941fca6f07e107afc447b7b248e340
147e83
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date:   Thu Jul 10 14:15:16 2014 +0530
147e83
147e83
    Fix crash when system has no ipv6 address [BZ #17125]
147e83
    
147e83
    Here's an updated patch to fix the crash in bug-ga2 when the system
147e83
    has no configured ipv6 address.  I have taken a different approach of
147e83
    using libc_freeres_fn instead of the libc_freeres_ptr since the former
147e83
    gives better control over what is freed; we need that since cache may
147e83
    or may not be allocated using malloc.
147e83
    
147e83
    Verified that bug-ga2 works correctly in both cases and does not have
147e83
    memory leaks in either of them.
147e83
147e83
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
147e83
index 6b28a735a14f1498..757853342d2af5f4 100644
147e83
--- a/sysdeps/unix/sysv/linux/check_pf.c
147e83
+++ b/sysdeps/unix/sysv/linux/check_pf.c
147e83
@@ -62,7 +62,7 @@ static struct cached_data noai6ai_cached =
147e83
     .in6ailen = 0
147e83
   };
147e83
 
147e83
-libc_freeres_ptr (static struct cached_data *cache);
147e83
+static struct cached_data *cache;
147e83
 __libc_lock_define_initialized (static, lock);
147e83
 
147e83
 
147e83
@@ -378,6 +378,12 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
147e83
   *seen_ipv6 = true;
147e83
 }
147e83
 
147e83
+/* Free the cache if it has been allocated.  */
147e83
+libc_freeres_fn (freecache)
147e83
+{
147e83
+  if (cache)
147e83
+    __free_in6ai (cache->in6ai);
147e83
+}
147e83
 
147e83
 void
147e83
 __free_in6ai (struct in6addrinfo *ai)