diff options
-rw-r--r-- | src/lj_crecord.c | 4 | ||||
-rw-r--r-- | src/lj_ctype.c | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index bc21d859..e0f581ca 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -1504,9 +1504,13 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) | |||
1504 | if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); | 1504 | if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); |
1505 | goto ok; | 1505 | goto ok; |
1506 | } else if (ctype_isfunc(ct->info)) { | 1506 | } else if (ctype_isfunc(ct->info)) { |
1507 | CTypeID id0 = i ? ctype_typeid(cts, s[0]) : 0; | ||
1507 | tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); | 1508 | tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); |
1508 | ct = ctype_get(cts, | 1509 | ct = ctype_get(cts, |
1509 | lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); | 1510 | lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); |
1511 | if (i) { | ||
1512 | s[0] = ctype_get(cts, id0); /* cts->tab may have been reallocated. */ | ||
1513 | } | ||
1510 | goto ok; | 1514 | goto ok; |
1511 | } else { | 1515 | } else { |
1512 | tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); | 1516 | tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); |
diff --git a/src/lj_ctype.c b/src/lj_ctype.c index 204be034..10322c00 100644 --- a/src/lj_ctype.c +++ b/src/lj_ctype.c | |||
@@ -191,8 +191,20 @@ CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size) | |||
191 | } | 191 | } |
192 | id = cts->top; | 192 | id = cts->top; |
193 | if (LJ_UNLIKELY(id >= cts->sizetab)) { | 193 | if (LJ_UNLIKELY(id >= cts->sizetab)) { |
194 | #ifdef LUAJIT_CTYPE_CHECK_ANCHOR | ||
195 | CType *ct; | ||
196 | #endif | ||
194 | if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); | 197 | if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); |
198 | #ifdef LUAJIT_CTYPE_CHECK_ANCHOR | ||
199 | ct = lj_mem_newvec(cts->L, id+1, CType); | ||
200 | memcpy(ct, cts->tab, id*sizeof(CType)); | ||
201 | memset(cts->tab, 0, id*sizeof(CType)); | ||
202 | lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType); | ||
203 | cts->tab = ct; | ||
204 | cts->sizetab = id+1; | ||
205 | #else | ||
195 | lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); | 206 | lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); |
207 | #endif | ||
196 | } | 208 | } |
197 | cts->top = id+1; | 209 | cts->top = id+1; |
198 | cts->tab[id].info = info; | 210 | cts->tab[id].info = info; |