diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-27 13:37:59 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-27 13:37:59 -0200 |
| commit | 3e41afcec550e8c5c3c4372f72efa48cbf7031a3 (patch) | |
| tree | 7ae0d003a8ba00b87aecebddc14ffd789a5a9b90 /ldo.c | |
| parent | 3acf5ec5a18c83ed0ce7e41c9b5789bddd2b3e60 (diff) | |
| download | lua-3e41afcec550e8c5c3c4372f72efa48cbf7031a3.tar.gz lua-3e41afcec550e8c5c3c4372f72efa48cbf7031a3.tar.bz2 lua-3e41afcec550e8c5c3c4372f72efa48cbf7031a3.zip | |
extra api checks for number of returns of C functions and for lua_yield
Diffstat (limited to 'ldo.c')
| -rw-r--r-- | ldo.c | 6 |
1 files changed, 5 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.72 2009/11/17 16:46:44 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.73 2009/11/25 15:27:51 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -311,6 +311,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 311 | lua_unlock(L); | 311 | lua_unlock(L); |
| 312 | n = (*curr_func(L)->c.f)(L); /* do the actual call */ | 312 | n = (*curr_func(L)->c.f)(L); /* do the actual call */ |
| 313 | lua_lock(L); | 313 | lua_lock(L); |
| 314 | api_checknelems(L, n); | ||
| 314 | luaD_poscall(L, L->top - n); | 315 | luaD_poscall(L, L->top - n); |
| 315 | return 1; | 316 | return 1; |
| 316 | } | 317 | } |
| @@ -382,6 +383,7 @@ static void finishCcall (lua_State *L) { | |||
| 382 | lua_unlock(L); | 383 | lua_unlock(L); |
| 383 | n = (*ci->u.c.k)(L); | 384 | n = (*ci->u.c.k)(L); |
| 384 | lua_lock(L); | 385 | lua_lock(L); |
| 386 | api_checknelems(L, n); | ||
| 385 | /* finish 'luaD_precall' */ | 387 | /* finish 'luaD_precall' */ |
| 386 | luaD_poscall(L, L->top - n); | 388 | luaD_poscall(L, L->top - n); |
| 387 | } | 389 | } |
| @@ -424,6 +426,7 @@ static void resume (lua_State *L, void *ud) { | |||
| 424 | lua_unlock(L); | 426 | lua_unlock(L); |
| 425 | n = (*ci->u.c.k)(L); /* call continuation */ | 427 | n = (*ci->u.c.k)(L); /* call continuation */ |
| 426 | lua_lock(L); | 428 | lua_lock(L); |
| 429 | api_checknelems(L, n); | ||
| 427 | firstArg = L->top - n; | 430 | firstArg = L->top - n; |
| 428 | } | 431 | } |
| 429 | G(L)->nCcalls--; /* finish 'luaD_call' */ | 432 | G(L)->nCcalls--; /* finish 'luaD_call' */ |
| @@ -511,6 +514,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { | |||
| 511 | CallInfo *ci = L->ci; | 514 | CallInfo *ci = L->ci; |
| 512 | luai_userstateyield(L, nresults); | 515 | luai_userstateyield(L, nresults); |
| 513 | lua_lock(L); | 516 | lua_lock(L); |
| 517 | api_checknelems(L, nresults); | ||
| 514 | if (L->nny > 0) | 518 | if (L->nny > 0) |
| 515 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); | 519 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); |
| 516 | L->status = LUA_YIELD; | 520 | L->status = LUA_YIELD; |
