diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-08 13:06:07 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-08 13:06:07 -0300 |
commit | aabe3ddbf4514b6c80258e731fbe90e74edcdc94 (patch) | |
tree | 825c152fde3b41a811f9c2e219525c7f6f91678a /lbaselib.c | |
parent | 0c258c84927ffe8540fc9590bdce802d598faa6a (diff) | |
download | lua-aabe3ddbf4514b6c80258e731fbe90e74edcdc94.tar.gz lua-aabe3ddbf4514b6c80258e731fbe90e74edcdc94.tar.bz2 lua-aabe3ddbf4514b6c80258e731fbe90e74edcdc94.zip |
errors in 'resume' should be all protected
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.214 2009/03/23 14:26:12 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.215 2009/04/08 18:04:33 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -512,8 +512,10 @@ static const luaL_Reg base_funcs[] = { | |||
512 | 512 | ||
513 | static int auxresume (lua_State *L, lua_State *co, int narg) { | 513 | static int auxresume (lua_State *L, lua_State *co, int narg) { |
514 | int status; | 514 | int status; |
515 | if (!lua_checkstack(co, narg)) | 515 | if (!lua_checkstack(co, narg)) { |
516 | return luaL_error(L, "too many arguments to resume"); | 516 | lua_pushliteral(L, "too many arguments to resume"); |
517 | return -1; /* error flag */ | ||
518 | } | ||
517 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { | 519 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { |
518 | lua_pushliteral(L, "cannot resume dead coroutine"); | 520 | lua_pushliteral(L, "cannot resume dead coroutine"); |
519 | return -1; /* error flag */ | 521 | return -1; /* error flag */ |
@@ -522,8 +524,10 @@ static int auxresume (lua_State *L, lua_State *co, int narg) { | |||
522 | status = lua_resume(co, narg); | 524 | status = lua_resume(co, narg); |
523 | if (status == LUA_OK || status == LUA_YIELD) { | 525 | if (status == LUA_OK || status == LUA_YIELD) { |
524 | int nres = lua_gettop(co); | 526 | int nres = lua_gettop(co); |
525 | if (!lua_checkstack(L, nres + 1)) | 527 | if (!lua_checkstack(L, nres + 1)) { |
526 | return luaL_error(L, "too many results to resume"); | 528 | lua_pushliteral(L, "too many results to resume"); |
529 | return -1; /* error flag */ | ||
530 | } | ||
527 | lua_xmove(co, L, nres); /* move yielded values */ | 531 | lua_xmove(co, L, nres); /* move yielded values */ |
528 | return nres; | 532 | return nres; |
529 | } | 533 | } |