Skip to content

Commit 38cc7d4

Browse files
committed
Bug: cannot allow the call 'debug.getinfo(0, ">")'
A 'what' argument starting with '>' indicates that there is a function in the C stack, which won't be there if the first argument is not a function.
1 parent bc97000 commit 38cc7d4

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

ldblib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static int db_getinfo (lua_State *L) {
152152
lua_State *L1 = getthread(L, &arg);
153153
const char *options = luaL_optstring(L, arg+2, "flnSrtu");
154154
checkstack(L, L1, 3);
155+
luaL_argcheck(L, options[0] != '>', arg + 2, "invalid option '>'");
155156
if (lua_isfunction(L, arg + 1)) { /* info about a function? */
156157
options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */
157158
lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */

testes/db.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ end
3131

3232
do
3333
assert(not pcall(debug.getinfo, print, "X")) -- invalid option
34+
assert(not pcall(debug.getinfo, 0, ">")) -- invalid option
3435
assert(not debug.getinfo(1000)) -- out of range level
3536
assert(not debug.getinfo(-1)) -- out of range level
3637
local a = debug.getinfo(print)

0 commit comments

Comments
 (0)