Changeset - r27443:1150c64644d0
[Not reviewed]
master
0 2 0
Loïc Guilloux - 17 months ago 2023-05-27 16:09:21
glx22@users.noreply.github.com
Fix: Check max member count in squirrel classes (#10883)

Manual cherry-pick from https://github.com/albertodemichelis/squirrel/commit/23a0620658714b996d20da3d4dd1a0dcf9b0bd98
2 files changed with 4 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/3rdparty/squirrel/squirrel/sqclass.cpp
Show inline comments
 
@@ -62,12 +62,15 @@ bool SQClass::NewSlot(SQSharedState *ss,
 
		return false; //the class already has an instance so cannot be modified
 
	if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
 
	{
 
		_defaultvalues[_member_idx(temp)].val = val;
 
		return true;
 
	}
 
	if (_members->CountUsed() >= MEMBER_MAX_COUNT) {
 
		return false;
 
	}
 
	if(type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE || bstatic) {
 
		SQInteger mmidx;
 
		if((type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE) &&
 
			(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
 
			_metamethods[mmidx] = val;
 
		}
src/3rdparty/squirrel/squirrel/sqclass.h
Show inline comments
 
@@ -16,12 +16,13 @@ struct SQClassMember {
 
};
 

	
 
typedef sqvector<SQClassMember> SQClassMemberVec;
 

	
 
#define MEMBER_TYPE_METHOD 0x01000000
 
#define MEMBER_TYPE_FIELD 0x02000000
 
#define MEMBER_MAX_COUNT 0x00FFFFFF
 

	
 
#define _ismethod(o) (_integer(o)&MEMBER_TYPE_METHOD)
 
#define _isfield(o) (_integer(o)&MEMBER_TYPE_FIELD)
 
#define _make_method_idx(i) ((SQInteger)(MEMBER_TYPE_METHOD|i))
 
#define _make_field_idx(i) ((SQInteger)(MEMBER_TYPE_FIELD|i))
 
#define _member_type(o) (_integer(o)&0xFF000000)
0 comments (0 inline, 0 general)