Skip to content
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

pointer to invalid LuaState in LuaObject #20

Open
IntendedConsequence opened this issue Jun 6, 2018 · 0 comments
Open

pointer to invalid LuaState in LuaObject #20

IntendedConsequence opened this issue Jun 6, 2018 · 0 comments

Comments

@IntendedConsequence
Copy link

In LuaObject's contructors and assignment operators, if src LuaObject happens to come from a coroutine then this LuaObject LuaState L will point to freed memory once the coroutine is garbage collected. Which results in all kinds of nasty business, especially in production code :(
From reading the reference, it appears that using lua_pushthread's return value of 1 for a non-coroutine lua_State should help identify that case and lua_xmove should transfer the object for a proper fastref in this's LuaObject's LuaState.

inline LuaObject::LuaObject(const LuaObject& src) throw() {
if (src.L) {
L = src.L;
#if LUA_FASTREF_SUPPORT
ref = lua_fastrefindex(L, src.ref);
#else
lua_getfastref(L, src.ref);
ref = lua_fastref(L);
#endif // LUA_FASTREF_SUPPORT
} else {
L = NULL;
ref = LUA_FASTREFNIL;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant