lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> However, if the internal variables are hidden from the Lua program,
there
>> is no need to do the checks on each iteration; it could be done in an
>> OP_FORPREP opcode.

> This is true only if your code was correctly generated by Lua. A
> "generic" binary code may change this hidden values during the looop.

That's true, but numbers are not pointers. It seems reasonable to assume
that whatever random bit pattern was placed in the number will at least add
and compare without doing any real damage.

Perhaps the test should be debug-time, instead, like this one:

      case OP_GETGLOBAL: {
        TObject *rb = KBx(i);
        const TObject *v;
        lua_assert(ttisstring(rb) && ttistable(&cl->g));
        v = luaH_getstr(hvalue(&cl->g), tsvalue(rb));

which has much more potential to segfault if the code has been incorrectly
generated (or even if setfenv was called with an incorrect argument.)