diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-13 10:51:42 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-13 10:51:42 -0200 |
commit | 36cf8f3a3c44da00cc9255797153df3c02895379 (patch) | |
tree | 58ae50fc37afb201dfcdcc1c17b0ef3ecbe89fc3 /loadlib.c | |
parent | 725c15a4caec1e40ea475c70224473b23a2d8a51 (diff) | |
download | lua-36cf8f3a3c44da00cc9255797153df3c02895379.tar.gz lua-36cf8f3a3c44da00cc9255797153df3c02895379.tar.bz2 lua-36cf8f3a3c44da00cc9255797153df3c02895379.zip |
Code should not change the stack level after the initialization of a
string buffer.
Diffstat (limited to 'loadlib.c')
-rw-r--r-- | loadlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.129 2016/12/04 20:17:24 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 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 | ** |
@@ -437,9 +437,9 @@ static const char *searchpath (lua_State *L, const char *name, | |||
437 | const char *sep, | 437 | const char *sep, |
438 | const char *dirsep) { | 438 | const char *dirsep) { |
439 | luaL_Buffer msg; /* to build error message */ | 439 | luaL_Buffer msg; /* to build error message */ |
440 | luaL_buffinit(L, &msg); | ||
441 | if (*sep != '\0') /* non-empty separator? */ | 440 | if (*sep != '\0') /* non-empty separator? */ |
442 | name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ | 441 | name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ |
442 | luaL_buffinit(L, &msg); | ||
443 | while ((path = pushnexttemplate(L, path)) != NULL) { | 443 | while ((path = pushnexttemplate(L, path)) != NULL) { |
444 | const char *filename = luaL_gsub(L, lua_tostring(L, -1), | 444 | const char *filename = luaL_gsub(L, lua_tostring(L, -1), |
445 | LUA_PATH_MARK, name); | 445 | LUA_PATH_MARK, name); |
@@ -569,10 +569,10 @@ static int searcher_preload (lua_State *L) { | |||
569 | static void findloader (lua_State *L, const char *name) { | 569 | static void findloader (lua_State *L, const char *name) { |
570 | int i; | 570 | int i; |
571 | luaL_Buffer msg; /* to build error message */ | 571 | luaL_Buffer msg; /* to build error message */ |
572 | luaL_buffinit(L, &msg); | ||
573 | /* push 'package.searchers' to index 3 in the stack */ | 572 | /* push 'package.searchers' to index 3 in the stack */ |
574 | if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE) | 573 | if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE) |
575 | luaL_error(L, "'package.searchers' must be a table"); | 574 | luaL_error(L, "'package.searchers' must be a table"); |
575 | luaL_buffinit(L, &msg); | ||
576 | /* iterate over available searchers to find a loader */ | 576 | /* iterate over available searchers to find a loader */ |
577 | for (i = 1; ; i++) { | 577 | for (i = 1; ; i++) { |
578 | if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ | 578 | if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ |