summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua51/loadlib.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/loadlib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
index 808368ba431..0d401eba1cf 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -506,8 +506,10 @@ static int ll_require (lua_State *L) {
static void setfenv (lua_State *L) {
lua_Debug ar;
- lua_getstack(L, 1, &ar);
- lua_getinfo(L, "f", &ar);
+ if (lua_getstack(L, 1, &ar) == 0 ||
+ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
+ lua_iscfunction(L, -1))
+ luaL_error(L, LUA_QL("module") " not called from a Lua function");
lua_pushvalue(L, -2);
lua_setfenv(L, -2);
lua_pop(L, 1);