diff --git a/lib/hostip.c b/lib/hostip.c
index 5876396b7153a950615f905a3dc53f2a8c0c056e..42cac050128cc9c5f53921358dbb61d69eefa526 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -605,6 +605,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data,
                                &h_errnop))==ERANGE) {
       step_size+=200;
     }
+    if(!h) /* failure */
+      res=1;
     
 #ifdef MALLOCDEBUG
     infof(data, "gethostbyname_r() uses %d bytes\n", step_size);