]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix io.close() error message.
authorMike Pall <mike>
Thu, 22 Jul 2021 14:21:45 +0000 (16:21 +0200)
committerMike Pall <mike>
Thu, 22 Jul 2021 14:21:45 +0000 (16:21 +0200)
Reported by François Perrad.

src/lib_io.c

index 76d3ace1955d1f97c251ab1e3b7073dee622bd94..35c57d8bd306a149753f4b749d70e773f79af400 100644 (file)
@@ -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);
 }