Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether a condition judgment is necessary. #63

Open
rodman10 opened this issue Jul 8, 2022 · 3 comments
Open

Whether a condition judgment is necessary. #63

rodman10 opened this issue Jul 8, 2022 · 3 comments

Comments

@rodman10
Copy link

rodman10 commented Jul 8, 2022

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 :)

@brimworks
Copy link
Owner

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.

@rodman10
Copy link
Author

rodman10 commented Jul 9, 2022

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.
16573535048526
Above is an example of empty parameters, lua_tolstring returns NULL if convert failed.

@brimworks
Copy link
Owner

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!

@brimworks brimworks reopened this Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants