From 69df01efb20fb7bd91f9a857c78da8d49a01e309 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 28 Mar 2010 03:34:18 +0200 Subject: Fix precondition check for NEWREF. A check for nil value is not enough. Must check for ptr == niltv. --- src/lj_record.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lj_record.c b/src/lj_record.c index 54068697..29c024bf 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -995,10 +995,10 @@ static TRef rec_idx(jit_State *J, RecordIndex *ix) cTValue *mo = lj_tab_getstr(mt, strref(J2G(J)->mmname[MM_newindex])); hasmm = mo && !tvisnil(mo); } - if (hasmm || oldv == niltvg(J2G(J))) + if (hasmm) emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ else if (xrefop == IR_HREF) - emitir(IRTG(IR_NE, IRT_PTR), xref, lj_ir_kptr(J, niltvg(J2G(J)))); + emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PTR), xref, lj_ir_kptr(J, niltvg(J2G(J)))); if (ix->idxchain && rec_mm_lookup(J, ix, MM_newindex)) { /* Metamethod? */ lua_assert(hasmm); goto handlemm; -- cgit v1.2.3-55-g6feb