From dce921c1cd8be6d5d0bb1cdac3de6781197052cd Mon Sep 17 00:00:00 2001 From: Librae Date: Mon, 27 Jul 2015 14:16:45 -0600 Subject: [PATCH] Check if DNS server has been initialized before trying to lookup the server address in the cache. From Librae --- libc/netdb/lib_dnsclient.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libc/netdb/lib_dnsclient.c b/libc/netdb/lib_dnsclient.c index 873022f459..a959005f53 100644 --- a/libc/netdb/lib_dnsclient.c +++ b/libc/netdb/lib_dnsclient.c @@ -1029,6 +1029,14 @@ int dns_find_answer(FAR const char *hostname, FAR struct sockaddr *addr, int next; int ndx; + /* If DNS not initialized, no need to proceed */ + + if (!g_dns_initialized) + { + ndbg("ERROR: DNS not initialized yet\n"); + return -EAGAIN; + } + /* Get exclusive access to the DNS cache */ dns_semtake();