This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4e7f3236330f02a08fcac3d73b66a8d0c20bc2c6
Author: meijian <[email protected]>
AuthorDate: Thu Oct 24 11:13:14 2024 +0800

    net/getifaddrs: fix coverity bug
    
    Signed-off-by: meijian <[email protected]>
---
 libs/libc/net/lib_getifaddrs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libs/libc/net/lib_getifaddrs.c b/libs/libc/net/lib_getifaddrs.c
index 2bb67dc806..4526b280b4 100644
--- a/libs/libc/net/lib_getifaddrs.c
+++ b/libs/libc/net/lib_getifaddrs.c
@@ -83,6 +83,11 @@ static FAR struct myifaddrs *getmutil_ipv6addr(int fd, 
struct lifreq *req,
   FAR struct sockaddr_in6 *ipv6addr;
   int index;
 
+  if (req == NULL || ifaddr == NULL)
+    {
+      return NULL;
+    }
+
   /* eth0:0 is the second ipaddr */
 
   for (index = 0; index < CONFIG_NETDEV_MAX_IPv6_ADDR - 1; index++)
@@ -108,7 +113,7 @@ static FAR struct myifaddrs *getmutil_ipv6addr(int fd, 
struct lifreq *req,
         }
 
       ifaddr->addrs.ifa_next = lib_zalloc(sizeof(*ifaddr));
-      if (ifaddr == NULL)
+      if (ifaddr->addrs.ifa_next == NULL)
         {
           return NULL;
         }

Reply via email to