aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2014-04-08 12:10:51 +0200
committerMike Pall <mike>2014-04-08 12:10:51 +0200
commit4ed3ee1f046618c5251baae3013f125b4cc7ca9c (patch)
tree49db7722bac6e6be8db60b3bc3e2791b9047512f /src
parent111b2e8711366b40161b4530f5f0a4fd08dc3420 (diff)
downloadluajit-4ed3ee1f046618c5251baae3013f125b4cc7ca9c.tar.gz
luajit-4ed3ee1f046618c5251baae3013f125b4cc7ca9c.tar.bz2
luajit-4ed3ee1f046618c5251baae3013f125b4cc7ca9c.zip
FFI: Fix cdata equality comparison against strings.
Diffstat (limited to 'src')
-rw-r--r--src/lj_carith.c4
-rw-r--r--src/lj_crecord.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/lj_carith.c b/src/lj_carith.c
index 92fe5597..36d7abb1 100644
--- a/src/lj_carith.c
+++ b/src/lj_carith.c
@@ -62,7 +62,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
62 TValue *o2 = i == 0 ? o+1 : o-1; 62 TValue *o2 = i == 0 ? o+1 : o-1;
63 CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); 63 CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid);
64 ca->ct[i] = NULL; 64 ca->ct[i] = NULL;
65 ca->p[i] = NULL; 65 ca->p[i] = (uint8_t *)strVdata(o);
66 ok = 0; 66 ok = 0;
67 if (ctype_isenum(ct->info)) { 67 if (ctype_isenum(ct->info)) {
68 CTSize ofs; 68 CTSize ofs;
@@ -73,7 +73,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
73 ok = 1; 73 ok = 1;
74 } else { 74 } else {
75 ca->ct[1-i] = ct; /* Use enum to improve error message. */ 75 ca->ct[1-i] = ct; /* Use enum to improve error message. */
76 ca->p[1-i] = (void *)(intptr_t)1; /* To make it unequal. */ 76 ca->p[1-i] = NULL;
77 break; 77 break;
78 } 78 }
79 } 79 }
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 71f3d069..8612f005 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1421,7 +1421,9 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
1421 ct = ctype_child(cts, cct); 1421 ct = ctype_child(cts, cct);
1422 tr = lj_ir_kint(J, (int32_t)ofs); 1422 tr = lj_ir_kint(J, (int32_t)ofs);
1423 } /* else: interpreter will throw. */ 1423 } /* else: interpreter will throw. */
1424 } /* else: interpreter will throw. */ 1424 } else {
1425 tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr)));
1426 }
1425 } else if (!tref_isnum(tr)) { 1427 } else if (!tref_isnum(tr)) {
1426 tr = 0; 1428 tr = 0;
1427 } 1429 }