diff --git a/dlls/winsock/async.c b/dlls/winsock/async.c
index 2271e234c19be2e93e0c9965e972ff9b0909ee1a..33b43d86d8f3f950ac4ad67362f9acd0c083c822 100644
--- a/dlls/winsock/async.c
+++ b/dlls/winsock/async.c
@@ -402,6 +402,16 @@ static DWORD WINAPI _async_queryfun(LPVOID arg) {
                         int ebufsize=1024;
                         struct hostent hostentry;
                         int locerr = ENOBUFS;
+#endif
+                        char buf[100];
+                        if( !(aq->host_name)) {
+                            aq->host_name = buf;
+                            if( gethostname( buf, 100) == -1) {
+                                fail = WSAENOBUFS; /* appropriate ? */
+                                break;
+                            }
+                        }
+#ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
                         he = NULL;
                         extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
                         while(extrabuf) {
diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c
index 757f4948ccf9b0661f9b57725df97f95e418b518..8f275735bfd6fcd465d12c6d7364852b27e92e36 100644
--- a/dlls/winsock/socket.c
+++ b/dlls/winsock/socket.c
@@ -2903,6 +2903,16 @@ static WIN_hostent * __ws_gethostbyname(const char *name, int dup_flag)
     int ebufsize=1024;
     struct hostent hostentry;
     int locerr = ENOBUFS;
+#endif
+    char buf[100];
+    if( !name) {
+        name = buf;
+        if( gethostname( buf, 100) == -1) {
+            SetLastError( WSAENOBUFS); /* appropriate ? */
+            return retval;
+        }
+    }
+#ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
     host = NULL;
     extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
     while(extrabuf) {