Original Post
Since I use AS there is a bug in the generic calling convention when returning auto handles.
When a function returns an autohandle, the generic callconv doesn't increase it's reference counter and later it is going to cause crashes. I've managed to fix this by adding
[source lang="cpp"] if ( sysFunction->returnType.IsObject()
&& !sysFunction->returnType.IsReference()
&& sysFunction->returnType.IsObjectHandle()
&& sysFunc->returnAutoHandle
&& m_regs.objectRegister )
m_engine->CallObjectMethod( m_regs.objectRegister, sysFunction->returnType.GetObjectType()->beh.addref );
[/source]
to the asCContext::CallGeneric function before "Clean up function parameters" (line 4382 in 2.24.1).
I'm using this for a long time now (copying it over upon AS upgrade), but not sure if this is the correct solution. It works though.
When a function returns an autohandle, the generic callconv doesn't increase it's reference counter and later it is going to cause crashes. I've managed to fix this by adding
[source lang="cpp"] if ( sysFunction->returnType.IsObject()
&& !sysFunction->returnType.IsReference()
&& sysFunction->returnType.IsObjectHandle()
&& sysFunc->returnAutoHandle
&& m_regs.objectRegister )
m_engine->CallObjectMethod( m_regs.objectRegister, sysFunction->returnType.GetObjectType()->beh.addref );
[/source]
to the asCContext::CallGeneric function before "Clean up function parameters" (line 4382 in 2.24.1).
I'm using this for a long time now (copying it over upon AS upgrade), but not sure if this is the correct solution. It works though.