diff options
author | Paul Kulchenko <paul@kulchenko.com> | 2022-03-18 02:23:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 12:23:09 +0300 |
commit | d9cc531e3bc62cfe7965c8cb3df7b1d510f3f4a2 (patch) | |
tree | b8b937bd2d665e69a9bb9df1e83a330ab2bf278e | |
parent | 5b18e475f38fcf28429b1cc4b17baee3b9793a62 (diff) | |
download | luasocket-d9cc531e3bc62cfe7965c8cb3df7b1d510f3f4a2.tar.gz luasocket-d9cc531e3bc62cfe7965c8cb3df7b1d510f3f4a2.tar.bz2 luasocket-d9cc531e3bc62cfe7965c8cb3df7b1d510f3f4a2.zip |
Fixe an issue with aux buffer init overwriting optional parameters in receive() (#334)
Fixes use on Lua >= 5.4.3
-rw-r--r-- | src/buffer.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) { | |||
103 | * object:receive() interface | 103 | * object:receive() interface |
104 | \*-------------------------------------------------------------------------*/ | 104 | \*-------------------------------------------------------------------------*/ |
105 | int buffer_meth_receive(lua_State *L, p_buffer buf) { | 105 | int buffer_meth_receive(lua_State *L, p_buffer buf) { |
106 | int err = IO_DONE, top = lua_gettop(L); | 106 | int err = IO_DONE, top; |
107 | luaL_Buffer b; | 107 | luaL_Buffer b; |
108 | size_t size; | 108 | size_t size; |
109 | const char *part = luaL_optlstring(L, 3, "", &size); | 109 | const char *part = luaL_optlstring(L, 3, "", &size); |
110 | timeout_markstart(buf->tm); | 110 | timeout_markstart(buf->tm); |
111 | /* make sure we don't confuse buffer stuff with arguments */ | ||
112 | lua_settop(L, 3); | ||
113 | top = lua_gettop(L); | ||
111 | /* initialize buffer with optional extra prefix | 114 | /* initialize buffer with optional extra prefix |
112 | * (useful for concatenating previous partial results) */ | 115 | * (useful for concatenating previous partial results) */ |
113 | luaL_buffinit(L, &b); | 116 | luaL_buffinit(L, &b); |