[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua reference re-use
- From: Chris Jones <cmsj@...>
- Date: Thu, 30 Jul 2015 11:46:54 +0100
If one does luaL_ref(), luaL_unref() and luaL_ref() again, there's a fair chance that the same reference number will be handed out twice.
I'm wondering if it would be better if the references handed out by luaL_ref() were only ever given out once? I think it would help track down use-after-free type bugs, where right now you get either confusing data of the wrong type, or take incorrect action on data that happens to be the right type.
Clearly this is only an issue in code that has bugs, but we know that all code has bugs, and I think finding them would be easier if a lua_rawgeti() on a reference that had been released, would be able to return a clear "NO YOU ARE DOING SOMETHING WRONG" error.