summary refs log tree commit diff
path: root/nss/getXXent.c
diff options
context:
space:
mode:
Diffstat (limited to 'nss/getXXent.c')
-rw-r--r--nss/getXXent.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/nss/getXXent.c b/nss/getXXent.c
index 2d6d1c32e6..f180171150 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -84,15 +84,22 @@ GETFUNC_NAME (void)
   while (buffer != NULL
 	 && INTERNAL (REENTRANT_GETNAME) (&resbuf, buffer, buffer_size, &result
 					  H_ERRNO_VAR) != 0
+#ifdef NEED_H_ERRNO
+	 && h_errno == NETDB_INTERNAL
+#endif
 	 && errno == ERANGE)
     {
       char *new_buf;
       buffer_size += BUFLEN;
       new_buf = realloc (buffer, buffer_size);
       if (new_buf == NULL)
-	/* We are out of memory.  Free the current buffer so that the
-	   process gets a chance for a normal termination.  */
-	free (buffer);
+	{
+	  /* We are out of memory.  Free the current buffer so that the
+	     process gets a chance for a normal termination.  */
+	  save = errno;
+	  free (buffer);
+	  __set_errno (save);
+	}
       buffer = new_buf;
     }