diff options
| -rw-r--r-- | lbaselib.c | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.245 2010/06/13 19:41:34 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.246 2010/07/02 11:38:13 roberto Exp roberto $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -330,11 +330,14 @@ static int luaB_load (lua_State *L) { | |||
| 330 | 330 | ||
| 331 | static int luaB_loadin (lua_State *L) { | 331 | static int luaB_loadin (lua_State *L) { |
| 332 | int n; | 332 | int n; |
| 333 | luaL_checktype(L, 1, LUA_TTABLE); | 333 | luaL_checkany(L, 1); |
| 334 | n = luaB_load_aux(L, 2); | 334 | n = luaB_load_aux(L, 2); |
| 335 | if (n == 1) { /* success? */ | 335 | if (n == 1) { /* success? */ |
| 336 | const char *name; | ||
| 336 | lua_pushvalue(L, 1); /* environment for loaded function */ | 337 | lua_pushvalue(L, 1); /* environment for loaded function */ |
| 337 | lua_setupvalue(L, -2, 1); | 338 | name = lua_setupvalue(L, -2, 1); |
| 339 | if (name == NULL || strcmp(name, "_ENV") != 0) | ||
| 340 | luaL_error(L, "loaded chunk does not have environment upvalue"); | ||
| 338 | } | 341 | } |
| 339 | return n; | 342 | return n; |
| 340 | } | 343 | } |
