LocalIP (Android): fix crashing

This commit is contained in:
李通洲
2023-07-17 23:40:59 +08:00
parent 59dc2f82e3
commit 1dc0ee183c
+3 -1
View File
@@ -17,10 +17,12 @@
#include <netpacket/packet.h>
#endif
#ifdef __linux__
#if defined(__linux__) || defined(__ANDROID__)
static bool getDefaultRoute(char iface[IF_NAMESIZE + 1])
{
FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r");
if (!netRoute) return false;
// skip first line
flockfile(netRoute);
while (getc_unlocked(netRoute) != '\n');