diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -430,14 +430,15 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) { | |||
430 | break; | 430 | break; |
431 | default: /* two/more results and/or to-be-closed variables */ | 431 | default: /* two/more results and/or to-be-closed variables */ |
432 | if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */ | 432 | if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */ |
433 | ptrdiff_t savedres = savestack(L, res); | ||
434 | L->ci->callstatus |= CIST_CLSRET; /* in case of yields */ | 433 | L->ci->callstatus |= CIST_CLSRET; /* in case of yields */ |
435 | L->ci->u2.nres = nres; | 434 | L->ci->u2.nres = nres; |
436 | luaF_close(L, res, CLOSEKTOP, 1); | 435 | res = luaF_close(L, res, CLOSEKTOP, 1); |
437 | L->ci->callstatus &= ~CIST_CLSRET; | 436 | L->ci->callstatus &= ~CIST_CLSRET; |
438 | if (L->hookmask) /* if needed, call hook after '__close's */ | 437 | if (L->hookmask) { /* if needed, call hook after '__close's */ |
438 | ptrdiff_t savedres = savestack(L, res); | ||
439 | rethook(L, L->ci, nres); | 439 | rethook(L, L->ci, nres); |
440 | res = restorestack(L, savedres); /* close and hook can move stack */ | 440 | res = restorestack(L, savedres); /* hook can move stack */ |
441 | } | ||
441 | wanted = decodeNresults(wanted); | 442 | wanted = decodeNresults(wanted); |
442 | if (wanted == LUA_MULTRET) | 443 | if (wanted == LUA_MULTRET) |
443 | wanted = nres; /* we want all results */ | 444 | wanted = nres; /* we want all results */ |
@@ -654,8 +655,7 @@ static int finishpcallk (lua_State *L, CallInfo *ci) { | |||
654 | else { /* error */ | 655 | else { /* error */ |
655 | StkId func = restorestack(L, ci->u2.funcidx); | 656 | StkId func = restorestack(L, ci->u2.funcidx); |
656 | L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ | 657 | L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ |
657 | luaF_close(L, func, status, 1); /* can yield or raise an error */ | 658 | func = luaF_close(L, func, status, 1); /* can yield or raise an error */ |
658 | func = restorestack(L, ci->u2.funcidx); /* stack may be moved */ | ||
659 | luaD_seterrorobj(L, status, func); | 659 | luaD_seterrorobj(L, status, func); |
660 | luaD_shrinkstack(L); /* restore stack size in case of overflow */ | 660 | luaD_shrinkstack(L); /* restore stack size in case of overflow */ |
661 | setcistrecst(ci, LUA_OK); /* clear original status */ | 661 | setcistrecst(ci, LUA_OK); /* clear original status */ |