Browse Source

Fix SLikeNet crash on android device. (#2424)

sssooonnnggg 6 years ago
parent
commit
c23f371fa5
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Source/ThirdParty/SLikeNet/Source/src/linux_adapter.cpp

+ 7 - 2
Source/ThirdParty/SLikeNet/Source/src/linux_adapter.cpp

@@ -1,4 +1,4 @@
-/*
+/*
  *  Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
  *  Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
  *
  *
  *  This source code is licensed under the MIT-style license found in the
  *  This source code is licensed under the MIT-style license found in the
@@ -989,7 +989,12 @@ static void interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, stru
 		{
 		{
 			l_mask[i] = 0xff;
 			l_mask[i] = 0xff;
 		}
 		}
-		l_mask[i] = 0xff << (8 - (l_prefix % 8));
+
+		// Avoid stack check fail on android device, reference https://github.com/libuv/libuv/blob/e4087dedf837f415056a45a838f639a3d9dc3ced/src/unix/android-ifaddrs.c
+		if (l_prefix % 8)
+		{
+			l_mask[i] = 0xff << (8 - (l_prefix % 8));
+		}
 
 
 		makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8);
 		makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8);
 		l_entry->ifa_netmask = (struct sockaddr *)l_addr;
 		l_entry->ifa_netmask = (struct sockaddr *)l_addr;