From 1dc0ee183c8f871d98809dfb8ea6a078915d9ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jul 2023 23:40:59 +0800 Subject: [PATCH] LocalIP (Android): fix crashing --- src/detection/localip/localip_linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index f1814f77f..f93ee6f9d 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -17,10 +17,12 @@ #include #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');