]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua: dlua_table_get() - Pop key from stack if idx doesn't point to a table
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 2 Jun 2021 16:48:48 +0000 (19:48 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 17 Jan 2022 11:52:09 +0000 (13:52 +0200)
Otherwise it leaks the key into the stack.

src/lib-lua/dlua-table.c

index 8467a7e695eaa4489aea9253e417b584b2379dc9..74afa1e6eb27dc303918f7030763324831aec49b 100644 (file)
@@ -37,8 +37,10 @@ static inline int adj(int idx, int delta)
 static int dlua_table_get(lua_State *L, int idx, int type)
 {
        /* can only work with tables */
-       if (!lua_istable(L, idx))
+       if (!lua_istable(L, idx)) {
+               lua_pop(L, 1);
                return -1;
+       }
 
        lua_gettable(L, idx);