From 388e31cb965d776483fdb6ea6b419f857a7ef5c2 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Wed, 24 Jun 2009 10:39:07 +0000 Subject: 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 --- apps/plugins/lua/lauxlib.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'apps') 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) { int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ lf.extraline = 0; lf.f = rb->open(filename, O_RDONLY); + lua_pushfstring(L, "@%s", filename); if(lf.f < 0) { /* Fallback */ @@ -613,12 +614,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { if(lf.f < 0) 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)); rb->close(lf.f); -- cgit v1.2.3