diff options
| -rw-r--r-- | lapi.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.12 2004/06/08 14:31:00 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.13 2004/06/30 14:15:23 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 | */ |
| @@ -677,12 +677,13 @@ LUA_API int lua_setfenv (lua_State *L, int idx) { | |||
| 677 | api_checknelems(L, 1); | 677 | api_checknelems(L, 1); |
| 678 | o = luaA_index(L, idx); | 678 | o = luaA_index(L, idx); |
| 679 | api_checkvalidindex(L, o); | 679 | api_checkvalidindex(L, o); |
| 680 | L->top--; | 680 | api_check(L, ttistable(L->top - 1)); |
| 681 | api_check(L, ttistable(L->top)); | ||
| 682 | if (isLfunction(o)) { | 681 | if (isLfunction(o)) { |
| 683 | res = 1; | 682 | res = 1; |
| 684 | clvalue(o)->l.g = *(L->top); | 683 | clvalue(o)->l.g = *(L->top - 1); |
| 684 | luaC_objbarrier(L, clvalue(o), hvalue(L->top - 1)); | ||
| 685 | } | 685 | } |
| 686 | L->top--; | ||
| 686 | lua_unlock(L); | 687 | lua_unlock(L); |
| 687 | return res; | 688 | return res; |
| 688 | } | 689 | } |
