Advertisement

CScriptHandle null

Started by September 05, 2018 10:28 AM
2 comments, last by Miss 6 years, 2 months ago

Is it possible to pass a null handle to ?&in parameters?

For example, in 2.32.0 this causes a null reference exception:


SomeObject@ obj = null;
ref x(obj);

The constructor for ref takes ?&in, so it kinda makes sense it dereferences it... Would it be possible to still catch when null is passed? (When passing non-null, the typeId passed to this function does not have the asTYPEID_OBJHANDLE flag set either.)

(I'd like to handle this case for a separate thing, but CScriptHandle is the easiest example to demonstrate the problem.)

Yes, it is possible to pass a null pointer to ?&in.

However in your test you're attempting to pass obj by value, which causes a null pointer exception when attempting to copy it before the call to the CScriptHandle constructor is performed.

The following two works.


SomeObject@ obj = null;
ref x(@obj);
ref y(null);

 

 

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

Ah, that explains a lot! Thank you.

This topic is closed to new replies.

Advertisement