mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Fix potential file descriptor leak in luaL_loadfile*().
Reported by Assumeru. #1249
This commit is contained in:
parent
86e7123bb1
commit
19db4e9b7c
@ -88,12 +88,13 @@ LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename,
|
|||||||
int status;
|
int status;
|
||||||
const char *chunkname;
|
const char *chunkname;
|
||||||
if (filename) {
|
if (filename) {
|
||||||
|
chunkname = lua_pushfstring(L, "@%s", filename);
|
||||||
ctx.fp = fopen(filename, "rb");
|
ctx.fp = fopen(filename, "rb");
|
||||||
if (ctx.fp == NULL) {
|
if (ctx.fp == NULL) {
|
||||||
|
L->top--;
|
||||||
lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno));
|
lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno));
|
||||||
return LUA_ERRFILE;
|
return LUA_ERRFILE;
|
||||||
}
|
}
|
||||||
chunkname = lua_pushfstring(L, "@%s", filename);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.fp = stdin;
|
ctx.fp = stdin;
|
||||||
chunkname = "=stdin";
|
chunkname = "=stdin";
|
||||||
|
Loading…
Reference in New Issue
Block a user