mirror of
https://github.com/lua/lua
synced 2024-12-29 13:49:44 +03:00
files should not be operated after fclose, even when fclose fails
This commit is contained in:
parent
fe8f4c06f1
commit
55e323190e
6
liolib.c
6
liolib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp roberto $
|
||||
** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp roberto $
|
||||
** Standard I/O (and system) library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -99,7 +99,7 @@ static FILE **newfile (lua_State *L) {
|
||||
static int io_pclose (lua_State *L) {
|
||||
FILE **p = topfile(L);
|
||||
int ok = lua_pclose(L, *p);
|
||||
if (ok) *p = NULL;
|
||||
*p = NULL;
|
||||
return pushresult(L, ok, NULL);
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ static int io_pclose (lua_State *L) {
|
||||
static int io_fclose (lua_State *L) {
|
||||
FILE **p = topfile(L);
|
||||
int ok = (fclose(*p) == 0);
|
||||
if (ok) *p = NULL;
|
||||
*p = NULL;
|
||||
return pushresult(L, ok, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user