lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Excerpts from William Ahern's message of 2014-04-29 01:59:57 +0200:
> I don't understand what the issue is. Can you describe it in more detail?
> Why would you push a stale pointer? A pointer is completely and utterly
> invalid after it's been freed, so even copying its value is invalid, as well
> as dereferencing it.

Passing a freed pointer is indeed a bug. The nil case is meant for
debug trap for it - ie lua_pushuserdata ...; assert(!lua_isnil(L, -1)).

With native implementation, one does not have way of knowing, the
invariant with userdata is always that if you keep using pointer to it
(not just for pushing by its value), you better make sure you have it
always anchored somewhere, too.