978e96
commit bd3b0fbae33a9a4cc5e2daf049443d5cf03d4251
978e96
Author: Andreas Schwab <schwab@suse.de>
978e96
Date:   Mon Nov 5 12:47:30 2018 +0100
978e96
978e96
    libanl: properly cleanup if first helper thread creation failed (bug 22927)
978e96
978e96
2018-11-05  Andreas Schwab  <schwab@suse.de>
978e96
978e96
	[BZ #22927]
978e96
	* resolv/gai_misc.c (__gai_enqueue_request): Don't crash if
978e96
	creating the first helper thread failed.
978e96
978e96
[Note from DJ - hard to test; must force second calloc() call in
978e96
getaddrinfo_a() to return NULL/ENOMEM]
978e96
978e96
diff -rup a/resolv/gai_misc.c b/resolv/gai_misc.c
978e96
--- a/resolv/gai_misc.c	2012-12-24 22:02:13.000000000 -0500
978e96
+++ b/resolv/gai_misc.c	2019-01-22 16:19:30.514199534 -0500
978e96
@@ -264,8 +264,11 @@ __gai_enqueue_request (struct gaicb *gai
978e96
 	      /* We cannot create a thread in the moment and there is
978e96
 		 also no thread running.  This is a problem.  `errno' is
978e96
 		 set to EAGAIN if this is only a temporary problem.  */
978e96
-	      assert (lastp->next == newp);
978e96
-	      lastp->next = NULL;
978e96
+	      assert (requests == newp || lastp->next == newp);
978e96
+	      if (lastp != NULL)
978e96
+		lastp->next = NULL;
978e96
+	      else
978e96
+		requests = NULL;
978e96
 	      requests_tail = lastp;
978e96
 
978e96
 	      newp->next = freelist;