small bug: should not use string after popping it

This commit is contained in:
Roberto Ierusalimschy 2006-07-03 17:16:49 -03:00
parent 74832b2a10
commit c7b89dd280
1 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp roberto $
** $Id: loadlib.c,v 1.53 2006/06/22 16:12:59 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@ -360,11 +360,12 @@ static const char *findfile (lua_State *L, const char *name,
while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename;
filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
lua_remove(L, -2); /* remove path template */
if (readable(filename)) /* does file exist and is readable? */
return filename; /* return that file name */
lua_pop(L, 2); /* remove path template and file name */
luaO_pushfstring(L, "\n\tno file " LUA_QS, filename);
lua_concat(L, 2);
lua_remove(L, -2); /* remove file name */
lua_concat(L, 2); /* add entry to possible error message */
}
return NULL; /* not found */
}