diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-06-24 10:39:07 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-06-24 10:39:07 +0000 |
commit | 388e31cb965d776483fdb6ea6b419f857a7ef5c2 (patch) | |
tree | ed5f0a1042c52afb3492305614b5957914c41837 /apps | |
parent | 3127150636b1eb6ef405ab4c81b7051b01238653 (diff) | |
download | rockbox-388e31cb965d776483fdb6ea6b419f857a7ef5c2.tar.gz rockbox-388e31cb965d776483fdb6ea6b419f857a7ef5c2.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lua/lauxlib.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/apps/plugins/lua/lauxlib.c b/apps/plugins/lua/lauxlib.c index 3f6d8e6f1b..0c987cfa30 100644 --- a/apps/plugins/lua/lauxlib.c +++ b/apps/plugins/lua/lauxlib.c | |||
@@ -598,6 +598,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { | |||
598 | int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ | 598 | int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ |
599 | lf.extraline = 0; | 599 | lf.extraline = 0; |
600 | lf.f = rb->open(filename, O_RDONLY); | 600 | lf.f = rb->open(filename, O_RDONLY); |
601 | lua_pushfstring(L, "@%s", filename); | ||
601 | if(lf.f < 0) { | 602 | if(lf.f < 0) { |
602 | /* Fallback */ | 603 | /* Fallback */ |
603 | 604 | ||
@@ -613,12 +614,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { | |||
613 | if(lf.f < 0) | 614 | if(lf.f < 0) |
614 | return errfile(L, "open", fnameindex); | 615 | return errfile(L, "open", fnameindex); |
615 | } | 616 | } |
616 | |||
617 | if(lf.f >= 0) | ||
618 | lua_pushfstring(L, "@%s", buffer); | ||
619 | } | 617 | } |
620 | else | ||
621 | lua_pushfstring(L, "@%s", filename); | ||
622 | 618 | ||
623 | status = lua_load(L, getF, &lf, lua_tostring(L, -1)); | 619 | status = lua_load(L, getF, &lf, lua_tostring(L, -1)); |
624 | rb->close(lf.f); | 620 | rb->close(lf.f); |