Advertisement

null pointer acess while LoadByteCode() Processing

Started by May 16, 2010 03:13 AM
1 comment, last by WitchLord 14 years, 9 months ago
revision: r589 script code

// note : use addon 'scriptarray'
void main()
{
    array< int > intArray = {0,1,2};
    uint tmp = intArray.length(); // program stoped while module->LoadByteCode() Processing
};

freeze code pos

// as_restore.cpp L1937
else if( c == asBC_CALL ||
		 c == asBC_CALLINTF ||
		 c == asBC_CALLSYS )
{
	// Translate the index to the func id
	int *fid = (int*)&bc[n+1];
	*fid = FindFunction(*fid)->id; // null pointer access
}

Please investigate.
Thanks for the report. I'll have this investigated as soon as possible.

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
Please exchange the methods asCRestore::WriteObjectType and ReadObjectType for the following:

void asCRestore::WriteObjectType(asCObjectType* ot) {	char ch;	// Only write the object type name	if( ot )	{		// Check for template instances/specializations		if( ot->templateSubType.GetTokenType() != ttUnrecognizedToken &&			ot != engine->defaultArrayObjectType )		{			ch = 'a';			WRITE_NUM(ch);			WriteString(&ot->name);			if( ot->templateSubType.IsObject() )			{				ch = 's';				WRITE_NUM(ch);				WriteObjectType(ot->templateSubType.GetObjectType());				if( ot->templateSubType.IsObjectHandle() )					ch = 'h';				else					ch = 'o';				WRITE_NUM(ch);			}			else			{				ch = 't';				WRITE_NUM(ch);				eTokenType t = ot->templateSubType.GetTokenType();				WRITE_NUM(t);			}		}		else if( ot->flags & asOBJ_TEMPLATE_SUBTYPE )		{			ch = 's';			WRITE_NUM(ch);			WriteString(&ot->name);		}		else		{			ch = 'o';			WRITE_NUM(ch);			WriteString(&ot->name);		}	}	else	{		ch = '\0';		WRITE_NUM(ch);	}}asCObjectType* asCRestore::ReadObjectType() {	asCObjectType *ot;	char ch;	READ_NUM(ch);	if( ch == 'a' )	{		// Read the name of the template type		asCString typeName;		ReadString(&typeName);		asCObjectType *tmpl = engine->GetObjectType(typeName.AddressOf());		READ_NUM(ch);		if( ch == 's' )		{			ot = ReadObjectType();			asCDataType dt = asCDataType::CreateObject(ot, false);			READ_NUM(ch);			if( ch == 'h' )				dt.MakeHandle(true);			if( tmpl->templateSubType.GetObjectType() == ot )				ot = tmpl;			else				ot = engine->GetTemplateInstanceType(tmpl, dt);						asASSERT(ot);		}		else		{			eTokenType tokenType;			READ_NUM(tokenType);			asCDataType dt = asCDataType::CreatePrimitive(tokenType, false);			ot = engine->GetTemplateInstanceType(tmpl, dt);						asASSERT(ot);		}	}	else if( ch == 's' )	{		// Read the name of the template subtype		asCString typeName;		ReadString(&typeName);		// Find the template subtype		for( asUINT n = 0; n < engine->templateSubTypes.GetLength(); n++ )		{			if( engine->templateSubTypes[n] && engine->templateSubTypes[n]->name == typeName )			{				ot = engine->templateSubTypes[n];				break;			}		}		// TODO: Should give a friendly error in case the template type isn't found		asASSERT(ot);	}	else if( ch == 'o' )	{		// Read the object type name		asCString typeName;		ReadString(&typeName);		if( typeName.GetLength() && typeName != "_builtin_object_" && typeName != "_builtin_function_" )		{			// Find the object type			ot = module->GetObjectType(typeName.AddressOf());			if( !ot )				ot = engine->GetObjectType(typeName.AddressOf());						asASSERT(ot);		}		else if( typeName == "_builtin_object_" )		{			ot = &engine->scriptTypeBehaviours;		}		else if( typeName == "_builtin_function_" )		{			ot = &engine->functionBehaviours;		}		else			assert( false );	}	else	{		// No object type		assert( ch == '\0' );		ot = 0;	}	return ot;}

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