diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -465,13 +465,13 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
465 | f = fvalue(s2v(func)); | 465 | f = fvalue(s2v(func)); |
466 | Cfunc: { | 466 | Cfunc: { |
467 | int n; /* number of returns */ | 467 | int n; /* number of returns */ |
468 | CallInfo *ci = next_ci(L); | 468 | CallInfo *ci; |
469 | checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ | 469 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ |
470 | L->ci = ci = next_ci(L); | ||
470 | ci->nresults = nresults; | 471 | ci->nresults = nresults; |
471 | ci->callstatus = CIST_C; | 472 | ci->callstatus = CIST_C; |
472 | ci->top = L->top + LUA_MINSTACK; | 473 | ci->top = L->top + LUA_MINSTACK; |
473 | ci->func = func; | 474 | ci->func = func; |
474 | L->ci = ci; | ||
475 | lua_assert(ci->top <= L->stack_last); | 475 | lua_assert(ci->top <= L->stack_last); |
476 | if (L->hookmask & LUA_MASKCALL) { | 476 | if (L->hookmask & LUA_MASKCALL) { |
477 | int narg = cast_int(L->top - func) - 1; | 477 | int narg = cast_int(L->top - func) - 1; |
@@ -485,12 +485,13 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
485 | break; | 485 | break; |
486 | } | 486 | } |
487 | case LUA_VLCL: { /* Lua function */ | 487 | case LUA_VLCL: { /* Lua function */ |
488 | CallInfo *ci = next_ci(L); | 488 | CallInfo *ci; |
489 | Proto *p = clLvalue(s2v(func))->p; | 489 | Proto *p = clLvalue(s2v(func))->p; |
490 | int narg = cast_int(L->top - func) - 1; /* number of real arguments */ | 490 | int narg = cast_int(L->top - func) - 1; /* number of real arguments */ |
491 | int nfixparams = p->numparams; | 491 | int nfixparams = p->numparams; |
492 | int fsize = p->maxstacksize; /* frame size */ | 492 | int fsize = p->maxstacksize; /* frame size */ |
493 | checkstackp(L, fsize, func); | 493 | checkstackGCp(L, fsize, func); |
494 | L->ci = ci = next_ci(L); | ||
494 | ci->nresults = nresults; | 495 | ci->nresults = nresults; |
495 | ci->u.l.savedpc = p->code; /* starting point */ | 496 | ci->u.l.savedpc = p->code; /* starting point */ |
496 | ci->callstatus = 0; | 497 | ci->callstatus = 0; |
@@ -504,7 +505,7 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
504 | break; | 505 | break; |
505 | } | 506 | } |
506 | default: { /* not a function */ | 507 | default: { /* not a function */ |
507 | checkstackp(L, 1, func); /* space for metamethod */ | 508 | checkstackGCp(L, 1, func); /* space for metamethod */ |
508 | luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ | 509 | luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ |
509 | goto retry; /* try again with metamethod */ | 510 | goto retry; /* try again with metamethod */ |
510 | } | 511 | } |