forked from len0rd/rockbox
Fix FS#10378: Lua crashes when loading non-existing files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21488 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3127150636
commit
388e31cb96
1 changed files with 1 additions and 5 deletions
|
@ -598,6 +598,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
|
||||||
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
|
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
|
||||||
lf.extraline = 0;
|
lf.extraline = 0;
|
||||||
lf.f = rb->open(filename, O_RDONLY);
|
lf.f = rb->open(filename, O_RDONLY);
|
||||||
|
lua_pushfstring(L, "@%s", filename);
|
||||||
if(lf.f < 0) {
|
if(lf.f < 0) {
|
||||||
/* Fallback */
|
/* Fallback */
|
||||||
|
|
||||||
|
@ -613,12 +614,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
|
||||||
if(lf.f < 0)
|
if(lf.f < 0)
|
||||||
return errfile(L, "open", fnameindex);
|
return errfile(L, "open", fnameindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lf.f >= 0)
|
|
||||||
lua_pushfstring(L, "@%s", buffer);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
lua_pushfstring(L, "@%s", filename);
|
|
||||||
|
|
||||||
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
|
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
|
||||||
rb->close(lf.f);
|
rb->close(lf.f);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue