mirror of https://github.com/rusefi/lua.git
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.
This commit is contained in:
parent
bc970005ce
commit
38cc7d40a4
1
ldblib.c
1
ldblib.c
|
@ -152,6 +152,7 @@ static int db_getinfo (lua_State *L) {
|
||||||
lua_State *L1 = getthread(L, &arg);
|
lua_State *L1 = getthread(L, &arg);
|
||||||
const char *options = luaL_optstring(L, arg+2, "flnSrtu");
|
const char *options = luaL_optstring(L, arg+2, "flnSrtu");
|
||||||
checkstack(L, L1, 3);
|
checkstack(L, L1, 3);
|
||||||
|
luaL_argcheck(L, options[0] != '>', arg + 2, "invalid option '>'");
|
||||||
if (lua_isfunction(L, arg + 1)) { /* info about a function? */
|
if (lua_isfunction(L, arg + 1)) { /* info about a function? */
|
||||||
options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */
|
options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */
|
||||||
lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */
|
lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */
|
||||||
|
|
|
@ -31,6 +31,7 @@ end
|
||||||
|
|
||||||
do
|
do
|
||||||
assert(not pcall(debug.getinfo, print, "X")) -- invalid option
|
assert(not pcall(debug.getinfo, print, "X")) -- invalid option
|
||||||
|
assert(not pcall(debug.getinfo, 0, ">")) -- invalid option
|
||||||
assert(not debug.getinfo(1000)) -- out of range level
|
assert(not debug.getinfo(1000)) -- out of range level
|
||||||
assert(not debug.getinfo(-1)) -- out of range level
|
assert(not debug.getinfo(-1)) -- out of range level
|
||||||
local a = debug.getinfo(print)
|
local a = debug.getinfo(print)
|
||||||
|
|
Loading…
Reference in New Issue