From baa1281efe45ba0ba97714dbc6f411e72b822a7c Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 31 Mar 2023 14:14:01 +0300 Subject: [PATCH] don't assume select returns refcount 1 array that probably would be a safe assumption right now, but who knows about the future; cpyWithShape should return back its argument directly if it already has refcount 1 anyway --- src/builtins/transpose.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtins/transpose.c b/src/builtins/transpose.c index f71fcb10..3ef94226 100644 --- a/src/builtins/transpose.c +++ b/src/builtins/transpose.c @@ -345,8 +345,9 @@ B transp_c2(B t, B w, B x) { else ind = M1C2(tbl, add, v, ind); } r = C2(select, ind, x); - if (rr>1) arr_shReplace(a(r), rr, sh); - else { decSh(v(r)); arr_shVec(a(r)); } + Arr* ra = cpyWithShape(r); r = taga(ra); + if (rr>1) arr_shReplace(ra, rr, sh); + else { decSh((Value*)ra); arr_shVec(ra); } ret:; TFREE(alloc);