mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Limit number of arguments given to io.lines() and fp:lines().
This commit is contained in:
parent
7f454aed82
commit
575bfe5028
15
src/lib_io.c
15
src/lib_io.c
@ -278,6 +278,15 @@ static int io_file_iter(lua_State *L)
|
||||
return n;
|
||||
}
|
||||
|
||||
static int io_file_lines(lua_State *L)
|
||||
{
|
||||
int n = (int)(L->top - L->base);
|
||||
if (n > LJ_MAX_UPVAL)
|
||||
lj_err_caller(L, LJ_ERR_UNPACK);
|
||||
lua_pushcclosure(L, io_file_iter, n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -- I/O file methods ---------------------------------------------------- */
|
||||
|
||||
#define LJLIB_MODULE_io_method
|
||||
@ -361,8 +370,7 @@ LJLIB_CF(io_method_setvbuf)
|
||||
LJLIB_CF(io_method_lines)
|
||||
{
|
||||
io_tofile(L);
|
||||
lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base));
|
||||
return 1;
|
||||
return io_file_lines(L);
|
||||
}
|
||||
|
||||
LJLIB_CF(io_method___gc)
|
||||
@ -492,8 +500,7 @@ LJLIB_CF(io_lines)
|
||||
} else { /* io.lines() iterates over stdin. */
|
||||
setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT));
|
||||
}
|
||||
lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base));
|
||||
return 1;
|
||||
return io_file_lines(L);
|
||||
}
|
||||
|
||||
LJLIB_CF(io_type)
|
||||
|
Loading…
Reference in New Issue
Block a user