From d9cc531e3bc62cfe7965c8cb3df7b1d510f3f4a2 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Fri, 18 Mar 2022 02:23:09 -0700 Subject: [PATCH] Fixe an issue with aux buffer init overwriting optional parameters in receive() (#334) Fixes use on Lua >= 5.4.3 --- src/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/buffer.c b/src/buffer.c index ac5c531..7148be3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -103,11 +103,14 @@ int buffer_meth_send(lua_State *L, p_buffer buf) { * object:receive() interface \*-------------------------------------------------------------------------*/ int buffer_meth_receive(lua_State *L, p_buffer buf) { - int err = IO_DONE, top = lua_gettop(L); + int err = IO_DONE, top; luaL_Buffer b; size_t size; const char *part = luaL_optlstring(L, 3, "", &size); timeout_markstart(buf->tm); + /* make sure we don't confuse buffer stuff with arguments */ + lua_settop(L, 3); + top = lua_gettop(L); /* initialize buffer with optional extra prefix * (useful for concatenating previous partial results) */ luaL_buffinit(L, &b);