浏览代码

bug: file:close cannot be called without a file.

Roberto Ierusalimschy 22 年之前
父节点
当前提交
0ec4c473df
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      liolib.c

+ 2 - 2
liolib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: liolib.c,v 2.42 2003/05/14 19:03:43 roberto Exp roberto $
+** $Id: liolib.c,v 2.43 2003/05/14 21:01:53 roberto Exp roberto $
 ** Standard I/O (and system) library
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -137,7 +137,7 @@ static int aux_close (lua_State *L) {
 
 
 
 
 static int io_close (lua_State *L) {
 static int io_close (lua_State *L) {
-  if (lua_isnone(L, 1))
+  if (lua_isnone(L, 1) && lua_type(L, lua_upvalueindex(1)) == LUA_TTABLE)
     lua_rawgeti(L, lua_upvalueindex(1), IO_OUTPUT);
     lua_rawgeti(L, lua_upvalueindex(1), IO_OUTPUT);
   return pushresult(L, aux_close(L), NULL);
   return pushresult(L, aux_close(L), NULL);
 }
 }