diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-31 17:28:45 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-31 17:28:45 -0300 |
commit | 4dd0622d0c5f94b46d1e72b75a7c734bfd709e0c (patch) | |
tree | d250577b560825956add02cae817a2d337b49630 | |
parent | ab2c3d5cdea7812b48127778359849dbc180349a (diff) | |
download | lua-4dd0622d0c5f94b46d1e72b75a7c734bfd709e0c.tar.gz lua-4dd0622d0c5f94b46d1e72b75a7c734bfd709e0c.tar.bz2 lua-4dd0622d0c5f94b46d1e72b75a7c734bfd709e0c.zip |
bug in luaL_getsubtable (calling lua_absindex not with original stack)
-rw-r--r-- | lauxlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.242 2012/03/19 22:57:14 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.243 2012/04/20 17:05:17 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -520,11 +520,11 @@ LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { | |||
520 | 520 | ||
521 | LUALIB_API int luaL_ref (lua_State *L, int t) { | 521 | LUALIB_API int luaL_ref (lua_State *L, int t) { |
522 | int ref; | 522 | int ref; |
523 | t = lua_absindex(L, t); | ||
524 | if (lua_isnil(L, -1)) { | 523 | if (lua_isnil(L, -1)) { |
525 | lua_pop(L, 1); /* remove from stack */ | 524 | lua_pop(L, 1); /* remove from stack */ |
526 | return LUA_REFNIL; /* `nil' has a unique fixed reference */ | 525 | return LUA_REFNIL; /* `nil' has a unique fixed reference */ |
527 | } | 526 | } |
527 | t = lua_absindex(L, t); | ||
528 | lua_rawgeti(L, t, freelist); /* get first free element */ | 528 | lua_rawgeti(L, t, freelist); /* get first free element */ |
529 | ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ | 529 | ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ |
530 | lua_pop(L, 1); /* remove it from stack */ | 530 | lua_pop(L, 1); /* remove it from stack */ |
@@ -866,8 +866,8 @@ LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { | |||
866 | lua_getfield(L, idx, fname); | 866 | lua_getfield(L, idx, fname); |
867 | if (lua_istable(L, -1)) return 1; /* table already there */ | 867 | if (lua_istable(L, -1)) return 1; /* table already there */ |
868 | else { | 868 | else { |
869 | idx = lua_absindex(L, idx); | ||
870 | lua_pop(L, 1); /* remove previous result */ | 869 | lua_pop(L, 1); /* remove previous result */ |
870 | idx = lua_absindex(L, idx); | ||
871 | lua_newtable(L); | 871 | lua_newtable(L); |
872 | lua_pushvalue(L, -1); /* copy to be left at top */ | 872 | lua_pushvalue(L, -1); /* copy to be left at top */ |
873 | lua_setfield(L, idx, fname); /* assign new table to field */ | 873 | lua_setfield(L, idx, fname); /* assign new table to field */ |