[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] lua_pushuserdata() polyfill
- From: Karel Tuma <kat@...>
- Date: Tue, 29 Apr 2014 19:17:01 +0200
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.