From b32b818df711cdfc87c1f156307eae386bdd4356 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 4 Jun 2022 00:35:22 +0300 Subject: [PATCH] fix m_shArr erroring within arr_shAlloc --- src/core/stuff.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/stuff.h b/src/core/stuff.h index 12e9229e..deaa913d 100644 --- a/src/core/stuff.h +++ b/src/core/stuff.h @@ -51,8 +51,12 @@ static void arr_shVec(Arr* x) { x->sh = &x->ia; } static usz* arr_shAlloc(Arr* x, ur r) { // sets rank, allocates & returns shape (or null if r<2) + if (r>1) { + usz* sh = x->sh = m_shArr(r)->a; + sprnk(x,r); // is m_shArr OOMs, rank is gonna stay the 0 from the initial write in allocL, which is "safe" + return sh; + } sprnk(x,r); - if (r>1) return x->sh = m_shArr(r)->a; x->sh = &x->ia; return NULL; }