Advertisement

CScriptArray accepts object type that is not its own

Started by December 08, 2014 12:10 PM
1 comment, last by WitchLord 9 years, 7 months ago

I create a CScriptArray in my code like this:


asIObjectType* pType = m_pScriptEngine->GetObjectTypeByName( "string" );
CScriptArray* pArray = CScriptArray::Create( pType );

The array accepts the type without checking if it's actually an array type, or if it even has a valid subtype.

The string stored in the array behaves as it should because i set the contents in C++, and is not directly accessed by script code,

however its destructor is not called, which is to be expected.

Should there be a script exception set and/or null pointer returned if the array type is invalid, or should i simply be more cautious about how i instantiate arrays?

Well, you will always need to be cautious to use the correct object type when creating the array objects.

However, I will definitely add a sanity check on the informed object type, so you will not have to discover the problem the hard way. Thanks for bringing this up. :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

I've added an assert in the CScriptArray constructor to verify the object type in revision 2148.

Regards,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement