fix GroupLen on array elements outside i64 range

This commit is contained in:
dzaima 2024-03-25 15:32:07 +02:00
parent 79ea9ec02c
commit 10a58878d7
2 changed files with 11 additions and 3 deletions

View File

@ -152,12 +152,18 @@ B fill_c2(B t, B w, B x) { // TODO not set fill for typed arrays
B grLen_both(i64 ria, B x) {
usz ia = IA(x);
if (ia==0) return taga(arr_shVec(allZeroes(ria<=0? 0 : ria)));
SGetU(x)
f64 xmaxf = -1;
for (usz i = 0; i < ia; i++) {
i64 c = o2i64G(GetU(x, i));
if (c>ria) ria = c;
f64 c = o2fG(GetU(x, i));
if (c>xmaxf) xmaxf = c;
}
if (xmaxf >= USZ_MAX) thrOOM();
if ((i64)xmaxf > ria) {
ria = (i64)xmaxf;
if (ria >= (i64)USZ_MAX) thrOOM();
}
if (ria > (i64)(USZ_MAX-1)) thrOOM();
ria++;
B r;
{

View File

@ -248,6 +248,8 @@ w←1‿1⥊1 ⋄ x←2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨•Repr𝕩,": Expe
# ⊔
!"⊔: ≠𝕨 must be either ≠𝕩 or one bigger (2≡≠𝕨, 3≡≠𝕩)" % 003
!"Out of memory" % "a"
!"Out of memory" % 1e50"a"
# ↕𝕩
!"Expected non-negative integer, got character" % @