diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-22 12:05:27 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-22 12:05:27 +0200 |
commit | 3ff3103e98b350712543f926c429ab339700e252 (patch) | |
tree | 61827d6b7dcb51c38f17f068c8b498c16a0db1c3 /lib/lua/src | |
parent | 350b6d175c406fbbc002237f37db4cf88d6d3d19 (diff) | |
parent | 9f338f5a56e5adee3d11d59827f7e2b8a714e6c2 (diff) | |
download | dragonfireclient-3ff3103e98b350712543f926c429ab339700e252.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'lib/lua/src')
-rw-r--r-- | lib/lua/src/lgc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/lua/src/lgc.c b/lib/lua/src/lgc.c index e909c79a9..9141a1c60 100644 --- a/lib/lua/src/lgc.c +++ b/lib/lua/src/lgc.c @@ -164,8 +164,13 @@ static int traversetable (global_State *g, Table *h) { markobject(g, h->metatable); mode = gfasttm(g, h->metatable, TM_MODE); if (mode && ttisstring(mode)) { /* is there a weak mode? */ - weakkey = (strchr(svalue(mode), 'k') != NULL); - weakvalue = (strchr(svalue(mode), 'v') != NULL); + // Android's 'FORTIFY libc' calls __builtin_object_size on the argument of strchr. + // This produces an incorrect size for the expression `svalue(mode)`, causing + // an assertion. By placing it in a temporary, __builtin_object_size returns + // -1 (for unknown size) which functions correctly. + const char *tmp = svalue(mode); + weakkey = (strchr(tmp, 'k') != NULL); + weakvalue = (strchr(tmp, 'v') != NULL); if (weakkey || weakvalue) { /* is really weak? */ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ h->marked |= cast_byte((weakkey << KEYWEAKBIT) | |