--- qemu/slirp/misc.c 2018/04/24 16:37:52 1.1.1.1 +++ qemu/slirp/misc.c 2018/04/24 16:41:51 1.1.1.2 @@ -88,15 +88,14 @@ void getouraddr() { char buff[256]; - struct hostent *he; + struct hostent *he = NULL; - if (gethostname(buff,256) < 0) - return; - - if ((he = gethostbyname(buff)) == NULL) - return; - - our_addr = *(struct in_addr *)he->h_addr; + if (gethostname(buff,256) == 0) + he = gethostbyname(buff); + if (he) + our_addr = *(struct in_addr *)he->h_addr; + if (our_addr.s_addr == 0) + our_addr.s_addr = loopback_addr.s_addr; } #if SIZEOF_CHAR_P == 8