diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-14 15:04:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-14 15:04:11 -0200 |
commit | 5d9b8b7cdc64777dd1ae071b52c1816fb1faa5e7 (patch) | |
tree | 5b35aecdfb285953765e9b2783f7518f22101eda /lapi.c | |
parent | 1c2501fad4de5a06407500587751d71f7331a872 (diff) | |
download | lua-5d9b8b7cdc64777dd1ae071b52c1816fb1faa5e7.tar.gz lua-5d9b8b7cdc64777dd1ae071b52c1816fb1faa5e7.tar.bz2 lua-5d9b8b7cdc64777dd1ae071b52c1816fb1faa5e7.zip |
more secure definition for lua_concat
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.128 2001/02/12 15:42:44 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.129 2001/02/13 16:17:53 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -707,14 +707,18 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
707 | 707 | ||
708 | 708 | ||
709 | LUA_API void lua_concat (lua_State *L, int n) { | 709 | LUA_API void lua_concat (lua_State *L, int n) { |
710 | StkId top; | ||
711 | LUA_LOCK(L); | 710 | LUA_LOCK(L); |
712 | api_check(L, n >= 2); | ||
713 | api_checknelems(L, n); | 711 | api_checknelems(L, n); |
714 | top = L->top; | 712 | if (n >= 2) { |
715 | luaV_strconc(L, n, top); | 713 | luaV_strconc(L, n, L->top); |
716 | L->top = top-(n-1); | 714 | L->top -= (n-1); |
717 | luaC_checkGC(L); | 715 | luaC_checkGC(L); |
716 | } | ||
717 | else if (n == 0) { /* push null string */ | ||
718 | setsvalue(L->top, luaS_newlstr(L, NULL, 0)); | ||
719 | api_incr_top(L); | ||
720 | } | ||
721 | /* else n == 1; nothing to do */ | ||
718 | LUA_UNLOCK(L); | 722 | LUA_UNLOCK(L); |
719 | } | 723 | } |
720 | 724 | ||