Whether a condition judgment is necessary.
I notice the following code snippet in lz_filter_impl function:
/* Do the actual deflate'ing: */
if (lua_gettop(L) > 0) {
stream->next_in = (unsigned char*)lua_tolstring(L, -1, &avail_in);
} else {
stream->next_in = NULL;
avail_in = 0;
}
however there is always a luaL_buffinit before this, so the stack may always larger than 0 ? Thanks for explanation :)
The lz_filter_impl may be called from Lua with no input parameters in which case we wouldn't want to call lua_tolstring() on a non-existent stack element.
Thanks for explanation, but if this jugement is for empty parameters, I think it should be > 1 because luaL_buffinit will always push an userdata on stack.
Above is an example of empty parameters, lua_tolstring returns NULL if convert failed.
Oh, that looks like an oversight on my part. Would you like to open a pull request to fix this?
I'm actually not actively using Lua in any of my projects right now, so motivation for me to maintain this is a bit low at this moment in time.
Thanks!