From 9600e4318e17ef73d73c1980008d648c1c98f959 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 8 Dec 2019 19:54:21 +0100 Subject: [PATCH] Don't use STRREF for pointer diff in string.find(). Thanks to Sergey Ostanevich and Vyacheslav Egorov. --- src/lj_ffrecord.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 849d7a27..cb374beb 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c @@ -949,7 +949,8 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd) str->len-(MSize)start, pat->len)) { TRef pos; emitir(IRTG(IR_NE, IRT_PGC), tr, trp0); - pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_PGC), trstr, tr0)); + /* Don't use STRREF of trstr. We need a pointer diff. */ + pos = emitir(IRTI(IR_SUB), emitir(IRTI(IR_SUB), tr, trstr), lj_ir_kint(J, sizeof(GCstr))); J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1)); J->base[1] = emitir(IRTI(IR_ADD), pos, trplen); rd->nres = 2;