-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cpp] Null Check Interfaces #11743
[cpp] Null Check Interfaces #11743
Conversation
Very nice, i will try it. |
Is there any way for me to directly download the pre constructed Mac executable file? I encountered difficulties constructing haxe from the code source. |
OK, I found it, thank you |
I cannot directly obtain version 4.3.5, it seems that I can only construct from the source. |
Is there a meaningful test we could add for this? |
Yeah, snippet in PR description segfaults without this fix, and exception can now be caught |
I've added a test to make sure accessing a null interface does throw. Also updated the generated code a bit so the null check is guarded behind the #ifdef HXCPP_CHECK_POINTER
if (!mPtr) NullReference("Object", true);
// The handler might have fixed up the null value
if (!mPtr) NullReference("Object", false);
#ifdef HXCPP_GC_CHECK_POINTER
GCCheckPointer(mPtr);
#endif
#endif
return mPtr; I have not done the double NullReference call as that boolean parameter "fixup" isn't used so I'm guessing its a hold over from a old implementation. |
* Add a IsNull check * escape quote * Add new line and remove unneeded dynamic * Guard interface null checks behind the same defines as class access * Add null interface exception test * move target guard to the right place...
Adds a null check to the interface object before we start casting, dereferencing, and doing anything which will cause an access violation.
With the current behaviour null interface access cannot be caught and you will not get stack traces, adding the null check means it can now be caught and you will get stack traces. The used
NullReference
function is also used by the hxcpp debugger, so null interfaces will no longer crash the debugger.