Fix drone crash at startup on Linux

The crash happens if there is a default route without a gateway in
the main routing table
This commit is contained in:
Srivats P 2022-12-23 13:14:19 +05:30
parent d44fdf4ae7
commit c07d9e8691

View File

@ -276,12 +276,14 @@ void LinuxPort::populateInterfaceInfo()
continue;
if (!gw4 && rtnl_route_get_family(rt) == AF_INET) {
gw4 = qFromBigEndian<quint32>(
nl_addr_get_binary_addr(rtnl_route_nh_get_gateway(nh)));
nl_addr *gwa = rtnl_route_nh_get_gateway(nh);
if (gwa)
gw4 = qFromBigEndian<quint32>(nl_addr_get_binary_addr(gwa));
}
else if (!gw6 && rtnl_route_get_family(rt) == AF_INET6) {
gw6 = UInt128((quint8*)
nl_addr_get_binary_addr(rtnl_route_nh_get_gateway(nh)));
nl_addr *gwa = rtnl_route_nh_get_gateway(nh);
if (gwa)
gw6 = UInt128((quint8*) nl_addr_get_binary_addr(gwa));
}
}