Skip to content

pointer to invalid LuaState in LuaObject #20

@IntendedConsequence

Description

@IntendedConsequence

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;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions