mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
FFI: Limit index range for complex numbers.
This commit is contained in:
parent
6fd721ce72
commit
992bc2caa3
@ -94,10 +94,12 @@ collect_attrib:
|
|||||||
if (ctype_ispointer(ct->info)) {
|
if (ctype_ispointer(ct->info)) {
|
||||||
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */
|
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */
|
||||||
if (sz != CTSIZE_INVALID) {
|
if (sz != CTSIZE_INVALID) {
|
||||||
if (ctype_isptr(ct->info))
|
if (ctype_isptr(ct->info)) {
|
||||||
p = (uint8_t *)cdata_getptr(p, ct->size);
|
p = (uint8_t *)cdata_getptr(p, ct->size);
|
||||||
else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX)))
|
} else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) {
|
||||||
|
if ((ct->info & CTF_COMPLEX)) idx &= 1;
|
||||||
*qual |= CTF_CONST; /* Valarray elements are constant. */
|
*qual |= CTF_CONST; /* Valarray elements are constant. */
|
||||||
|
}
|
||||||
*pp = p + idx*(int32_t)sz;
|
*pp = p + idx*(int32_t)sz;
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,10 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd)
|
|||||||
#endif
|
#endif
|
||||||
integer_key:
|
integer_key:
|
||||||
if (ctype_ispointer(ct->info)) {
|
if (ctype_ispointer(ct->info)) {
|
||||||
CTSize sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info)));
|
CTSize sz;
|
||||||
|
if ((ct->info & CTF_COMPLEX))
|
||||||
|
idx = emitir(IRT(IR_BAND, IRT_INTP), idx, lj_ir_kintp(J, 1));
|
||||||
|
sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info)));
|
||||||
idx = crec_reassoc_ofs(J, idx, &ofs, sz);
|
idx = crec_reassoc_ofs(J, idx, &ofs, sz);
|
||||||
idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz));
|
idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz));
|
||||||
ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr);
|
ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user