Check for or handle argument length >2⋆31 in /⁼
This commit is contained in:
parent
194e8c3f22
commit
342cadfc00
@ -951,10 +951,10 @@ B slash_im(B t, B x) {
|
|||||||
case el_i32: {
|
case el_i32: {
|
||||||
i32* xp = i32any_ptr(x);
|
i32* xp = i32any_ptr(x);
|
||||||
TRY_SMALL_OUT(32)
|
TRY_SMALL_OUT(32)
|
||||||
|
if (xia>I32_MAX) thrM("/⁼: Argument too large");
|
||||||
INIT_RES(32,ria)
|
INIT_RES(32,ria)
|
||||||
simd_count_i32_i32(rp, xp, xia);
|
simd_count_i32_i32(rp, xp, xia);
|
||||||
r = num_squeeze(r);
|
r = num_squeeze(r); break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#undef TRY_SMALL_OUT
|
#undef TRY_SMALL_OUT
|
||||||
#undef INIT_RES
|
#undef INIT_RES
|
||||||
@ -968,10 +968,12 @@ B slash_im(B t, B x) {
|
|||||||
TALLOC(usz, t, ria); \
|
TALLOC(usz, t, ria); \
|
||||||
for (usz j=0; j<ria; j++) t[j]=0; \
|
for (usz j=0; j<ria; j++) t[j]=0; \
|
||||||
for (usz i = 0; i < xia; i++) t[xp[i]]++; \
|
for (usz i = 0; i < xia; i++) t[xp[i]]++; \
|
||||||
i32* rp; r = m_i32arrv(&rp, ria); vfor (usz i=0; i<ria; i++) rp[i]=t[i]; \
|
if (xia<=I32_MAX) { i32* rp; r = m_i32arrv(&rp, ria); vfor (usz i=0; i<ria; i++) rp[i]=t[i]; } \
|
||||||
|
else { f64* rp; r = m_f64arrv(&rp, ria); vfor (usz i=0; i<ria; i++) rp[i]=t[i]; } \
|
||||||
TFREE(t); \
|
TFREE(t); \
|
||||||
r = num_squeeze(r); break; }
|
r = num_squeeze(r); break; }
|
||||||
CASE(8) CASE(16) CASE(32)
|
CASE(8) CASE(16) CASE(32)
|
||||||
|
#undef CASE
|
||||||
#endif
|
#endif
|
||||||
case el_f64: {
|
case el_f64: {
|
||||||
f64* xp = f64any_ptr(x);
|
f64* xp = f64any_ptr(x);
|
||||||
@ -983,6 +985,7 @@ B slash_im(B t, B x) {
|
|||||||
u64* rp; r = m_bitarrv(&rp, ria); for (usz i=0; i<BIT_N(ria); i++) rp[i]=0;
|
u64* rp; r = m_bitarrv(&rp, ria); for (usz i=0; i<BIT_N(ria); i++) rp[i]=0;
|
||||||
for (usz i = 0; i < xia; i++) bitp_set(rp, xp[i], 1);
|
for (usz i = 0; i < xia; i++) bitp_set(rp, xp[i], 1);
|
||||||
} else {
|
} else {
|
||||||
|
if (xia>I32_MAX) thrM("/⁼: Argument too large");
|
||||||
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0;
|
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0;
|
||||||
for (usz i = 0; i < xia; i++) rp[(usz)xp[i]]++;
|
for (usz i = 0; i < xia; i++) rp[(usz)xp[i]]++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user