Skip to content

Commit

Permalink
Attempt to fix double delete in Lua, see #216.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Aug 29, 2021
1 parent aac830e commit 58b252a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Include/RmlUi/Lua/LuaType.inl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ int LuaType<T>::gc_T(lua_State* L)
{
delete obj;
obj = nullptr;

// Change the field to not gc the next time we encounter this pointer. This may be necessary in case the
// just deleted object shared an address with a previously deleted (non-GCed) object, the latter which
// this function will be called upon later.
lua_pushboolean(L, 1); // ->[4] = true
lua_setfield(L, -2, name); // represents t[k] = v, [-2 = 3] = t -> v = [4], k = <ClassName>; pop [4]
}
}
lua_pop(L,3); //balance function
Expand Down

0 comments on commit 58b252a

Please sign in to comment.