aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-03 17:16:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-03 17:16:49 -0300
commitc7b89dd28097296bbc14d9b47b4cea72514b2b76 (patch)
tree042703ad8f2fbc2dbef970f22501498862c9b38d /loadlib.c
parent74832b2a1005f480963324b5464e20e16fc73ceb (diff)
downloadlua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.tar.gz
lua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.tar.bz2
lua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.zip
small bug: should not use string after popping it
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/loadlib.c b/loadlib.c
index 41082e59..6964b567 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.53 2006/06/22 16:12:59 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -360,11 +360,12 @@ static const char *findfile (lua_State *L, const char *name,
360 while ((path = pushnexttemplate(L, path)) != NULL) { 360 while ((path = pushnexttemplate(L, path)) != NULL) {
361 const char *filename; 361 const char *filename;
362 filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); 362 filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
363 lua_remove(L, -2); /* remove path template */
363 if (readable(filename)) /* does file exist and is readable? */ 364 if (readable(filename)) /* does file exist and is readable? */
364 return filename; /* return that file name */ 365 return filename; /* return that file name */
365 lua_pop(L, 2); /* remove path template and file name */
366 luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); 366 luaO_pushfstring(L, "\n\tno file " LUA_QS, filename);
367 lua_concat(L, 2); 367 lua_remove(L, -2); /* remove file name */
368 lua_concat(L, 2); /* add entry to possible error message */
368 } 369 }
369 return NULL; /* not found */ 370 return NULL; /* not found */
370} 371}