🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

CScriptHandle null

Started by
2 comments, last by Miss 5 years, 9 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.)

Advertisement

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

Ah, that explains a lot! Thank you.

This topic is closed to new replies.

Advertisement