fix 𝕨/𝕩 doing unchecked multiplications on +´𝕨

both that explicit one, and ones in the allocation functions
This commit is contained in:
dzaima 2025-05-22 01:36:09 +03:00
parent 3b5497e329
commit 36ba160477
2 changed files with 8 additions and 1 deletions

View File

@ -666,6 +666,7 @@ B slash_c2(B t, B w, B x) {
goto arrW_base;
}
s = usum(w);
if (s>=USZ_MAX) thrOOM();
if (xl>6 || (xl<3 && xl!=0)) goto arrW_base;
if (s<=wia) {
if (s==0) { r = zeroCells(x); goto decWX_ret; }
@ -678,8 +679,11 @@ B slash_c2(B t, B w, B x) {
arrW_base:
SLOW2("𝕨/𝕩", w, x);
B xf = getFillR(x);
ux ria = s;
usz csz = arr_csz(x);
MAKE_MUT_INIT(r0, s*csz, TI(x,elType)); MUTG_INIT(r0);
mulOn(ria, csz);
if (s>=USZ_MAX) thrOOM();
MAKE_MUT_INIT(r0, ria, TI(x,elType)); MUTG_INIT(r0);
SGetU(w)
B wc; usz ri=0;
if (csz!=1) { for (ux i=0; i<wia; i++) { if (!q_usz(wc=GetU(w,i))) goto pfree; usz c=o2sG(wc); for(ux j=0;j<c;j++) { mut_copyG(r0, ri, x, i*csz, csz); ri+= csz; } } }

View File

@ -122,6 +122,9 @@ w←1‿1⥊1 ⋄ x←2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨"𝕨",•Repr𝕩,
!"Integer out of range: 4.611686018427388e18" % 1,262 / 2<0 %USZ32
!"Out of memory" % 1,262 / 22<0 %USZ64
!"Out of memory" % 1,262 / 2<0 %USZ64
!"Out of memory" % (1e13×1000) / 1000
!"Out of memory" % (16 ¯1e9 + 260) / 16
!"Out of memory" % (4260)/4,281
4, 0, 5 / 445@ %% 6010@
4, 40, 5 / 445@ %% 6010@
102 / ¨ ["ab","cd","ef"] %% ¨ ["ab","ef","ef"]