BUG: pointer arithmetic does not have to work when pointing outside

an array.
This commit is contained in:
Roberto Ierusalimschy
1996-11-22 11:08:28 -02:00
parent 1f4ee4a4d2
commit d8b0bbb2ad

View File

@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
*/ */
char *rcs_opcode="$Id: opcode.c,v 3.76 1996/09/24 21:46:44 roberto Exp roberto $"; char *rcs_opcode="$Id: opcode.c,v 3.77 1996/11/18 13:48:44 roberto Exp roberto $";
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>
@@ -399,11 +399,11 @@ void lua_error (char *s)
lua_Function lua_stackedfunction (int level) lua_Function lua_stackedfunction (int level)
{ {
Object *p = top; StkId i;
while (--p >= stack) for (i = (top-1)-stack; i>=0; i--)
if (p->tag == LUA_T_MARK || p->tag == LUA_T_CMARK) if (stack[i].tag == LUA_T_MARK || stack[i].tag == LUA_T_CMARK)
if (level-- == 0) if (level-- == 0)
return Ref(p); return Ref(stack+i);
return LUA_NOOBJECT; return LUA_NOOBJECT;
} }