]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
luawrapper: correct lua_pop argument 16334/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 21 Oct 2025 17:11:22 +0000 (19:11 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 21 Oct 2025 17:11:24 +0000 (19:11 +0200)
a negative argument to _pop has defined behaviour but never
does what the user expects.

Note that none of this matters as Lua will adjust the stack to
the 1 top item, which is the pushed boolean, after `return 1`

but I get confused every time I read the negative version

Signed-off-by: Peter van Dijk <peter.van.dijk@powerdns.com>
ext/luawrapper/include/LuaContext.hpp

index b7de2c1c4379f1bef3600a3fc0d388208a36c43b..46f865d549f02ee37b6af46750ddbb4ddf2ab3fb 100644 (file)
@@ -123,7 +123,7 @@ public:
           lua_gettable(lua, -2);
           /* if not found, return false */
           if (lua_isnil(lua, -1)) {
-            lua_pop(lua, -2);
+            lua_pop(lua, 2);
             lua_pushboolean(lua, false);
             return 1;
           }