diff options
author | Mike Pall <mike> | 2011-09-28 17:29:15 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-09-28 17:29:15 +0200 |
commit | 76a2a7c857d0aa1dcbfc1cb6928b2faa5e2d33b3 (patch) | |
tree | eabfbd45888a1d41a65e84e350d1895acf536dbe | |
parent | 3c998f6c3c991c7ce5bab9d369ec7d8a3eefb615 (diff) | |
download | luajit-76a2a7c857d0aa1dcbfc1cb6928b2faa5e2d33b3.tar.gz luajit-76a2a7c857d0aa1dcbfc1cb6928b2faa5e2d33b3.tar.bz2 luajit-76a2a7c857d0aa1dcbfc1cb6928b2faa5e2d33b3.zip |
Avoid overwriting argument with error from metacall recording.
-rw-r--r-- | src/lj_ffrecord.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 067f66cf..6cdd79a9 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c | |||
@@ -297,15 +297,17 @@ static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm) | |||
297 | copyTV(J->L, &ix.tabv, &rd->argv[0]); | 297 | copyTV(J->L, &ix.tabv, &rd->argv[0]); |
298 | if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ | 298 | if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ |
299 | int errcode; | 299 | int errcode; |
300 | TValue argv0; | ||
300 | /* Temporarily insert metamethod below object. */ | 301 | /* Temporarily insert metamethod below object. */ |
301 | J->base[1] = J->base[0]; | 302 | J->base[1] = J->base[0]; |
302 | J->base[0] = ix.mobj; | 303 | J->base[0] = ix.mobj; |
304 | copyTV(J->L, &argv0, &rd->argv[0]); | ||
303 | copyTV(J->L, &rd->argv[1], &rd->argv[0]); | 305 | copyTV(J->L, &rd->argv[1], &rd->argv[0]); |
304 | copyTV(J->L, &rd->argv[0], &ix.mobjv); | 306 | copyTV(J->L, &rd->argv[0], &ix.mobjv); |
305 | /* Need to protect lj_record_tailcall because it may throw. */ | 307 | /* Need to protect lj_record_tailcall because it may throw. */ |
306 | errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); | 308 | errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); |
307 | /* Always undo Lua stack changes to avoid confusing the interpreter. */ | 309 | /* Always undo Lua stack changes to avoid confusing the interpreter. */ |
308 | copyTV(J->L, &rd->argv[0], &rd->argv[1]); | 310 | copyTV(J->L, &rd->argv[0], &argv0); |
309 | if (errcode) | 311 | if (errcode) |
310 | lj_err_throw(J->L, errcode); /* Propagate errors. */ | 312 | lj_err_throw(J->L, errcode); /* Propagate errors. */ |
311 | rd->nres = -1; /* Pending call. */ | 313 | rd->nres = -1; /* Pending call. */ |