Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Palsson <karlp@etactica.com>2020-06-30 13:38:42 +0300
committerPetr Štetiar <ynezz@true.cz>2020-07-11 12:15:12 +0300
commitc0941d3289fc0f1468ad6384f7af141cfd4adead (patch)
treeacbd77adcea23367f491d6860edd83fd4ff557b5
parent161c25960ba23e46ff960e84f25055f94758b909 (diff)
lua/uloop: make get_sock_fd capable of absolute addresses
The original code required the use of relative addresses into the lua stack. It should accept either. Signed-off-by: Karl Palsson <karlp@etactica.com>
-rw-r--r--lua/uloop.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lua/uloop.c b/lua/uloop.c
index fcbe274..394970d 100644
--- a/lua/uloop.c
+++ b/lua/uloop.c
@@ -188,7 +188,8 @@ static int get_sock_fd(lua_State* L, int idx) {
lua_getfield(L, idx, "getfd");
if(lua_isnil(L, -1))
return luaL_error(L, "socket type missing 'getfd' method");
- lua_pushvalue(L, idx - 1);
+ /* if we have absolute, no need to adjust for getfield() call */
+ lua_pushvalue(L, idx > 0 ? idx: idx - 1);
lua_call(L, 1, 1);
fd = lua_tointeger(L, -1);
lua_pop(L, 1);