-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix ObjectRef crashes due to lua_isnil() #10564
Conversation
I'd been meaning to ask this on the cleanup PR but it got merged before I got around. Oh well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Shouldn't all of the checks be isnoneornil? |
Idk, for some functions is kind of silly to declare them like |
Imho, none and You could add the missing |
Yeah, makes sense to remove the boolean and int/float specialisations with default values, and instead use: template <typename T>
inline T readParam(lua_State *L, int index, const T &default_value)
{
return lua_isnoneornil(L, index) ? default_value : readParam<T>(L, index);
} |
Ruben suggestion addressed. Also, I've added a couple more readParam: |
LGTM |
btw note that |
Treat 'none' values as 'nil'
So, according to Lua, when a value is not specified is not
nil
, butno value
. And they're not the same. This should fix itTo do
This PR is Ready for Review.
How to test
Spawn an armorball and it shouldn't crash anymore