From 2f4f271e996d8127e7e63fa8f986839c18bbf57a Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Thu, 28 Aug 2025 03:56:15 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E5=91=8A?= =?UTF-8?q?=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- device/cmds/src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/device/cmds/src/main.cpp b/device/cmds/src/main.cpp index b2cc8438e..6ec22a8ce 100644 --- a/device/cmds/src/main.cpp +++ b/device/cmds/src/main.cpp @@ -67,7 +67,10 @@ std::string GetLoopbackAddress() struct ifaddrs* ifAddrStruct = nullptr; void* tmpAddrPtr = nullptr; - getifaddrs(&ifAddrStruct); + if (getifaddrs(&ifAddrStruct) == -1) { // -1 : fail + printf("error: %s\n", COMMON::GetErrorMsg().c_str()); + return ""; + } while (ifAddrStruct != nullptr) { if (ifAddrStruct->ifa_addr == nullptr) { ifAddrStruct = ifAddrStruct->ifa_next; -- Gitee