diff --git a/utils.c b/utils.c
index 1ecbc215a582c8163e68a1984551abe524fe93f5..ebe2b37294413a32726b3049eece95e5e5d0c4de 100755
--- a/utils.c
+++ b/utils.c
@@ -137,7 +137,7 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
 		return NULL;
 	res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &herrno);
 
-	if (res || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0])
+	if (res || !result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0])
 		return NULL;
 	return &hp->hp;
 }