From: Jim Meyering Date: Thu, 19 May 1994 22:18:30 +0000 (+0000) Subject: GNU shell utilities X-Git-Tag: SHELLUTILS-1_10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39bbd361c18f688f72799e280f60d1ba765f6791;p=thirdparty%2Fgnulib.git GNU shell utilities --- diff --git a/lib/xgethostname.c b/lib/xgethostname.c index 86408e775d..9973b45bed 100644 --- a/lib/xgethostname.c +++ b/lib/xgethostname.c @@ -46,12 +46,12 @@ xgethostname () 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);