summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2021-07-22 16:21:45 +0200
committerMike Pall <mike>2021-07-22 16:21:45 +0200
commitd87da3d5fed7f046c426d6a747bb84c2880f4e8d (patch)
treeae1bbf2470118fb3f66d313981cbe116a335a563
parent8430f774e6478b587664ac4b7d4eb0b46678eff5 (diff)
downloadluajit2-d87da3d5fed7f046c426d6a747bb84c2880f4e8d.tar.gz
Fix io.close() error message.
Reported by François Perrad.
-rw-r--r--src/lib_io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib_io.c b/src/lib_io.c
index 76d3ace1..35c57d8b 100644
--- a/src/lib_io.c
+++ b/src/lib_io.c
@@ -293,8 +293,14 @@ static int io_file_lines(lua_State *L)
LJLIB_CF(io_method_close)
{
- IOFileUD *iof = L->base < L->top ? io_tofile(L) :
- io_stdfile(L, GCROOT_IO_OUTPUT);
+ IOFileUD *iof;
+ if (L->base < L->top) {
+ iof = io_tofile(L);
+ } else {
+ iof = IOSTDF_IOF(L, GCROOT_IO_OUTPUT);
+ if (iof->fp == NULL)
+ lj_err_caller(L, LJ_ERR_IOCLFL);
+ }
return io_file_close(L, iof);
}