diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-09-25 14:05:49 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-09-25 14:05:49 -0300 |
| commit | c04d9b9ecb7a9dcf59ba185fc6211cb1a3ee1706 (patch) | |
| tree | 0fb23f553f7a31a1450923204e7a6bb97b412032 | |
| parent | c44c68450a636647caea90872582e03a30bfb6e4 (diff) | |
| download | lua-c04d9b9ecb7a9dcf59ba185fc6211cb1a3ee1706.tar.gz lua-c04d9b9ecb7a9dcf59ba185fc6211cb1a3ee1706.tar.bz2 lua-c04d9b9ecb7a9dcf59ba185fc6211cb1a3ee1706.zip | |
small bug when closing closures in error conditions
Diffstat (limited to '')
| -rw-r--r-- | ldo.c | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.138 2001/07/16 20:24:48 roberto Exp $ | 2 | ** $Id: ldo.c,v 1.140 2001/09/07 17:39:10 roberto Exp $ |
| 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 | */ |
| @@ -192,8 +192,10 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) { | |||
| 192 | func = L->top - (nargs+1); /* function to be called */ | 192 | func = L->top - (nargs+1); /* function to be called */ |
| 193 | c.func = func; c.nresults = nresults; | 193 | c.func = func; c.nresults = nresults; |
| 194 | status = luaD_runprotected(L, f_call, &c); | 194 | status = luaD_runprotected(L, f_call, &c); |
| 195 | if (status != 0) /* an error occurred? */ | 195 | if (status != 0) { /* an error occurred? */ |
| 196 | luaF_close(L, func); /* close eventual pending closures */ | ||
| 196 | L->top = func; /* remove parameters from the stack */ | 197 | L->top = func; /* remove parameters from the stack */ |
| 198 | } | ||
| 197 | lua_unlock(L); | 199 | lua_unlock(L); |
| 198 | return status; | 200 | return status; |
| 199 | } | 201 | } |
| @@ -344,7 +346,6 @@ int luaD_runprotected (lua_State *L, void (*f)(lua_State *, void *), void *ud) { | |||
| 344 | if (setjmp(lj.b) == 0) | 346 | if (setjmp(lj.b) == 0) |
| 345 | (*f)(L, ud); | 347 | (*f)(L, ud); |
| 346 | else { /* an error occurred: restore the state */ | 348 | else { /* an error occurred: restore the state */ |
| 347 | luaF_close(L, lj.top); /* close eventual pending closures */ | ||
| 348 | L->ci = lj.ci; | 349 | L->ci = lj.ci; |
| 349 | L->top = lj.top; | 350 | L->top = lj.top; |
| 350 | L->allowhooks = lj.allowhooks; | 351 | L->allowhooks = lj.allowhooks; |
