diff --git a/device/cmds/src/main.cpp b/device/cmds/src/main.cpp index b2cc8438e49d870f8c9656a5e66ef28cd2088a73..6ec22a8cef9be6120a70328110ea95351fd0466c 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;