diff options
author | Mike Pall <mike> | 2023-12-10 19:42:22 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2023-12-10 19:42:22 +0100 |
commit | ff204d0350575cf710f6f4af982db146cb454e1a (patch) | |
tree | ad7e3a23d924e8e44f984055f4873a133424f208 /src | |
parent | 8d5ea4ceb9da28eb281940e693bd859b72ef24cb (diff) | |
download | luajit-ff204d0350575cf710f6f4af982db146cb454e1a.tar.gz luajit-ff204d0350575cf710f6f4af982db146cb454e1a.tar.bz2 luajit-ff204d0350575cf710f6f4af982db146cb454e1a.zip |
Fix anchoring for string buffer set() method (again).
Thanks to Peter Cawley. #1125
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_ffrecord.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index c70793a4..30dc6bfc 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c | |||
@@ -1205,14 +1205,11 @@ static void LJ_FASTCALL recff_buffer_method_set(jit_State *J, RecordFFData *rd) | |||
1205 | TRef trp = emitir(IRT(IR_STRREF, IRT_PGC), tr, lj_ir_kint(J, 0)); | 1205 | TRef trp = emitir(IRT(IR_STRREF, IRT_PGC), tr, lj_ir_kint(J, 0)); |
1206 | TRef len = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); | 1206 | TRef len = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); |
1207 | IRIns *irp = IR(tref_ref(trp)); | 1207 | IRIns *irp = IR(tref_ref(trp)); |
1208 | /* Anchor (potentially different) obj into which trp points after fold. */ | 1208 | /* trp must point into the anchored obj, even after folding. */ |
1209 | if (irp->o == IR_STRREF) { | 1209 | if (irp->o == IR_STRREF) |
1210 | tr = irp->op1; | 1210 | tr = irp->op1; |
1211 | } else if (irp->o == IR_KKPTR && !tref_isk(tr)) { | 1211 | else if (!tref_isk(tr)) |
1212 | GCstr *str = strV(&rd->argv[1]); /* Constify the argument. */ | 1212 | trp = emitir(IRT(IR_ADD, IRT_PGC), tr, lj_ir_kintpgc(J, sizeof(GCstr))); |
1213 | tr = lj_ir_kstr(J, str); | ||
1214 | trp = lj_ir_kkptr(J, (char *)strdata(str)); | ||
1215 | } | ||
1216 | lj_ir_call(J, IRCALL_lj_bufx_set, trbuf, trp, len, tr); | 1213 | lj_ir_call(J, IRCALL_lj_bufx_set, trbuf, trp, len, tr); |
1217 | #if LJ_HASFFI | 1214 | #if LJ_HASFFI |
1218 | } else if (tref_iscdata(tr)) { | 1215 | } else if (tref_iscdata(tr)) { |