netdb/getaddrinfo: fix NULL pointer reference

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-03-19 00:57:37 +08:00 committed by Petro Karashchenko
parent 6a212b1a2c
commit 484b930fd1

View File

@ -290,11 +290,10 @@ int getaddrinfo(FAR const char *hostname, FAR const char *servname,
if (ai != NULL) if (ai != NULL)
{ {
*res = (FAR struct addrinfo *)ai; *res = (FAR struct addrinfo *)ai;
} if (flags & AI_CANONNAME)
{
if (flags & AI_CANONNAME) ai->ai.ai_canonname = (FAR char *)hostname;
{ }
ai->ai.ai_canonname = (FAR char *)hostname;
} }
return (*res != NULL) ? OK : EAI_MEMORY; return (*res != NULL) ? OK : EAI_MEMORY;