changeset 221:39fde758aab1

GNU shell utilities
author Jim Meyering <jim@meyering.net>
date Thu, 19 May 1994 22:18:30 +0000
parents 9dcd6b796719
children a19e9d12945f
files lib/xgethostname.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -46,12 +46,12 @@
   int err;
 
   size = INITIAL_HOSTNAME_LENGTH;
+  hostname = xmalloc (size);
   while (1)
     {
-      hostname = xmalloc (size);
       hostname[size - 1] = '\0';
       err = gethostname (hostname, size);
-      if (err || hostname[size - 1] == '\0')
+      if (err == 0 && hostname[size - 1] == '\0')
 	break;
       size *= 2;
       hostname = xrealloc (hostname, size);