summaryrefslogtreecommitdiff
path: root/drivers/unix/ip_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix/ip_unix.cpp')
-rw-r--r--drivers/unix/ip_unix.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index 2015a4041d..05eedccc1d 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -113,8 +113,9 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
if (result == nullptr || result->ai_addr == nullptr) {
ERR_PRINT("Invalid response from getaddrinfo");
- if (result)
+ if (result) {
freeaddrinfo(result);
+ }
return IP_Address();
};
@@ -218,13 +219,15 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
getifaddrs(&ifAddrStruct);
for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) {
- if (!ifa->ifa_addr)
+ if (!ifa->ifa_addr) {
continue;
+ }
family = ifa->ifa_addr->sa_family;
- if (family != AF_INET && family != AF_INET6)
+ if (family != AF_INET && family != AF_INET6) {
continue;
+ }
Map<String, Interface_Info>::Element *E = r_interfaces->find(ifa->ifa_name);
if (!E) {
@@ -240,8 +243,9 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr));
}
- if (ifAddrStruct != nullptr)
+ if (ifAddrStruct != nullptr) {
freeifaddrs(ifAddrStruct);
+ }
}
#endif