Avoid overwriting argument with error from metacall recording.

This commit is contained in:
Mike Pall 2011-09-28 17:29:15 +02:00
parent 3c998f6c3c
commit 76a2a7c857

View File

@ -297,15 +297,17 @@ static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm)
copyTV(J->L, &ix.tabv, &rd->argv[0]); copyTV(J->L, &ix.tabv, &rd->argv[0]);
if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */
int errcode; int errcode;
TValue argv0;
/* Temporarily insert metamethod below object. */ /* Temporarily insert metamethod below object. */
J->base[1] = J->base[0]; J->base[1] = J->base[0];
J->base[0] = ix.mobj; J->base[0] = ix.mobj;
copyTV(J->L, &argv0, &rd->argv[0]);
copyTV(J->L, &rd->argv[1], &rd->argv[0]); copyTV(J->L, &rd->argv[1], &rd->argv[0]);
copyTV(J->L, &rd->argv[0], &ix.mobjv); copyTV(J->L, &rd->argv[0], &ix.mobjv);
/* Need to protect lj_record_tailcall because it may throw. */ /* Need to protect lj_record_tailcall because it may throw. */
errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp);
/* Always undo Lua stack changes to avoid confusing the interpreter. */ /* Always undo Lua stack changes to avoid confusing the interpreter. */
copyTV(J->L, &rd->argv[0], &rd->argv[1]); copyTV(J->L, &rd->argv[0], &argv0);
if (errcode) if (errcode)
lj_err_throw(J->L, errcode); /* Propagate errors. */ lj_err_throw(J->L, errcode); /* Propagate errors. */
rd->nres = -1; /* Pending call. */ rd->nres = -1; /* Pending call. */