aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2013-05-29 23:05:05 +0200
committerMike Pall <mike>2013-05-29 23:05:05 +0200
commit3eeb7d3aa02259e93db6e4816909e80acb57f8f8 (patch)
tree7bf0ba87b63f3088fbc70f902031622251e91984 /src
parent5a261dd92c72d8f9d2aab0714ce9e051f0d70219 (diff)
downloadluajit-3eeb7d3aa02259e93db6e4816909e80acb57f8f8.tar.gz
luajit-3eeb7d3aa02259e93db6e4816909e80acb57f8f8.tar.bz2
luajit-3eeb7d3aa02259e93db6e4816909e80acb57f8f8.zip
FFI: Preserve intermediate string for const char * conversion.
Otherwise the trailing NUL is lost.
Diffstat (limited to 'src')
-rw-r--r--src/lj_crecord.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 8577de2c..df98e6ec 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -618,7 +618,7 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval)
618 emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); 618 emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE));
619 sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); 619 sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE);
620 } else { 620 } else {
621 sp = emitir(IRT(IR_ADD, IRT_P32), sp, lj_ir_kint(J, sizeof(GCudata))); 621 sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCudata)));
622 } 622 }
623 } else if (tref_isstr(sp)) { 623 } else if (tref_isstr(sp)) {
624 if (ctype_isenum(d->info)) { /* Match string against enum constant. */ 624 if (ctype_isenum(d->info)) { /* Match string against enum constant. */
@@ -636,7 +636,8 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval)
636 } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ 636 } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */
637 lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */ 637 lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */
638 } else { /* Otherwise pass the string data as a const char[]. */ 638 } else { /* Otherwise pass the string data as a const char[]. */
639 sp = emitir(IRT(IR_STRREF, IRT_P32), sp, lj_ir_kint(J, 0)); 639 /* Don't use STRREF. It folds with SNEW, which loses the trailing NUL. */
640 sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCstr)));
640 sid = CTID_A_CCHAR; 641 sid = CTID_A_CCHAR;
641 } 642 }
642 } else { /* NYI: tref_istab(sp), tref_islightud(sp). */ 643 } else { /* NYI: tref_istab(sp), tref_islightud(sp). */