diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-07-03 17:16:49 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-07-03 17:16:49 -0300 |
| commit | c7b89dd28097296bbc14d9b47b4cea72514b2b76 (patch) | |
| tree | 042703ad8f2fbc2dbef970f22501498862c9b38d | |
| parent | 74832b2a1005f480963324b5464e20e16fc73ceb (diff) | |
| download | lua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.tar.gz lua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.tar.bz2 lua-c7b89dd28097296bbc14d9b47b4cea72514b2b76.zip | |
small bug: should not use string after popping it
| -rw-r--r-- | loadlib.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -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 | } |
