update from main archive 961201
[platform/upstream/glibc.git] / nss / getXXent.c
index 2d6d1c3..f180171 100644 (file)
@@ -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;
     }