[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: 'module' function setting function environment
- From: "Peter Cawley" <lua@...>
- Date: Wed, 16 Jul 2008 02:41:15 +0100
The setfenv function in loadlib.c obtains the function calling
'module' and then sets the environment of said function. I see two
potential problems here:
1) No check is made to ensure that there _is_ a calling function. Thus
if module is called directly from C with no other functions on the
stack, then the lua_Debug structure will be uninitialized, leading to
a seg fault in most cases.
2) Base lib's 'setfenv' function makes sure that you do not set the
environment of a C function, while 'module' does not. Thus if the
calling function is a C one, then bad things could happen as the C
function's environment is overwritten.
Are these actual problems, or am I seeing problems where there are none?