]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
table_print: simplify vararg handling
authorPetr Špaček <petr.spacek@nic.cz>
Thu, 11 Apr 2019 13:13:21 +0000 (15:13 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 11 Apr 2019 13:14:22 +0000 (15:14 +0200)
daemon/lua/sandbox.lua.in

index 7ba776cd251bbf1741b35063e940dceebbeda00e..b09c87f87088690413bd25e85ef5868d26667157 100644 (file)
@@ -389,20 +389,15 @@ local function funcsign(f)
                                local debuginfo = debug.getinfo(2)
                                if debuginfo.what == 'C' then  -- names N/A
                                        table.insert(func_args, '?')
-                               end
-                               if debug.getlocal(2, -1) then
-                                       -- vararg function
+                               elseif debuginfo.isvararg then
                                        table.insert(func_args, "...")
                                end
                                debug.sethook(oldhook)
                                error('aborting the call to introspected function')
                        end
                end
-       oldhook = debug.sethook(hook, "c")  -- invoke hook() on function call
-       -- fake arguments, necessary to detect vararg functions
-       local fakearg = {}
-       for _ = 1, 64 do fakearg[#fakearg + 1] = true end
-       f(unpack(fakearg)) -- huh?
+               oldhook = debug.sethook(hook, "c")  -- invoke hook() on function call
+               f(unpack({}))  -- huh?
        end)
        return "(" .. table.concat(func_args, ", ") .. ")"
 end