diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-05-08 17:14:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-05-08 17:14:16 -0300 |
commit | 55e323190eda0aac78c4cd13ba70c7f13d6f248b (patch) | |
tree | a9db435f5fd1493e8f49dc6b0c25c22d8cc2c89c | |
parent | fe8f4c06f1949851eccebf59afbe69f132ab40e8 (diff) | |
download | lua-55e323190eda0aac78c4cd13ba70c7f13d6f248b.tar.gz lua-55e323190eda0aac78c4cd13ba70c7f13d6f248b.tar.bz2 lua-55e323190eda0aac78c4cd13ba70c7f13d6f248b.zip |
files should not be operated after fclose, even when fclose fails
-rw-r--r-- | liolib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -99,7 +99,7 @@ static FILE **newfile (lua_State *L) { | |||
99 | static int io_pclose (lua_State *L) { | 99 | static int io_pclose (lua_State *L) { |
100 | FILE **p = topfile(L); | 100 | FILE **p = topfile(L); |
101 | int ok = lua_pclose(L, *p); | 101 | int ok = lua_pclose(L, *p); |
102 | if (ok) *p = NULL; | 102 | *p = NULL; |
103 | return pushresult(L, ok, NULL); | 103 | return pushresult(L, ok, NULL); |
104 | } | 104 | } |
105 | 105 | ||
@@ -107,7 +107,7 @@ static int io_pclose (lua_State *L) { | |||
107 | static int io_fclose (lua_State *L) { | 107 | static int io_fclose (lua_State *L) { |
108 | FILE **p = topfile(L); | 108 | FILE **p = topfile(L); |
109 | int ok = (fclose(*p) == 0); | 109 | int ok = (fclose(*p) == 0); |
110 | if (ok) *p = NULL; | 110 | *p = NULL; |
111 | return pushresult(L, ok, NULL); | 111 | return pushresult(L, ok, NULL); |
112 | } | 112 | } |
113 | 113 | ||