Fix angelscript segfault in BarbarianAI of recoil-rts. Found by fabien@

who also came up with the fix.

see https://github.com/anjo76/angelscript/pull/72
This commit is contained in:
thfr
2026-05-31 22:40:21 +00:00
parent d44741f106
commit f236de024d
2 changed files with 38 additions and 0 deletions
+1
View File
@@ -10,6 +10,7 @@ COMMENT = real-time strategy game engine for Beyond All Reason
V = 2025.06.24
PKGNAME = recoil-rts-${V}
REVISION = 0
DIST_TUPLE += github beyond-all-reason RecoilEngine ${V} .
DIST_TUPLE += github mikke89 RmlUi \
@@ -0,0 +1,37 @@
https://github.com/anjo76/angelscript/pull/72
Index: AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp
--- AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp.orig
+++ AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp
@@ -675,17 +675,23 @@ int CallSystemFunction(int id, asCContext *context)
// Skip the object pointer
args += AS_PTR_SIZE;
}
-
- // Add the base offset for multiple inheritance
+ if( obj )
+ {
+ // For composition we need to add the offset and/or dereference the pointer
+ obj = (void*)((char*)obj + sysFunc->compositeOffset);
+ if (sysFunc->isCompositeIndirect) obj = *((void**)obj);
+
+ // Add the base offset for multiple inheritance
#if (defined(__GNUC__) && (defined(AS_ARM64) || defined(AS_ARM) || defined(AS_MIPS))) || defined(AS_PSVITA)
- // On GNUC + ARM the lsb of the offset is used to indicate a virtual function
- // and the whole offset is thus shifted one bit left to keep the original
- // offset resolution
- // MIPS also work like ARM in this regard
- obj = (void*)(asPWORD(obj) + (sysFunc->baseOffset>>1));
+ // On GNUC + ARM the lsb of the offset is used to indicate a virtual function
+ // and the whole offset is thus shifted one bit left to keep the original
+ // offset resolution
+ // MIPS also work like ARM in this regard
+ obj = (void*)(asPWORD(obj) + (sysFunc->baseOffset>>1));
#else
- obj = (void*)(asPWORD(obj) + sysFunc->baseOffset);
+ obj = (void*)(asPWORD(obj) + sysFunc->baseOffset);
#endif
+ }
}
#else // !defined(AS_NO_THISCALL_FUNCTOR_METHOD)