From 55263bcbc48c9aa2809d2328722019347fbc1720 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 6 Sep 2022 12:40:18 -0400 Subject: [PATCH] Handle bit selection from arrays with under 2 elements --- src/builtins/select.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index e70f6de1..549e4137 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -63,6 +63,7 @@ B select_c2(B t, B w, B x) { return r; } usz xia = IA(x); + if (xia==0) thrM("โŠ: Indexing out-of-bounds (0โ‰กโ‰ ๐•ฉ)"); u8 xe = TI(x,elType); u8 we = TI(w,elType); #if SINGELI @@ -100,7 +101,12 @@ B select_c2(B t, B w, B x) { for (usz i=0; i < wia; i++) HARR_ADD(r, i, Get(x, WRAP(wp[i], xia, thrF("โŠ: Indexing out-of-bounds (%iโˆŠ๐•จ, %sโ‰กโ‰ ๐•ฉ)", wp[i], xia)))); \ decG(x); return withFill(HARR_FCD(r,w),xf); \ } - if (we==el_bit && xia>=2) { + if (we==el_bit) { + if (xia<2) { + u64* wp=bitarr_ptr(w); + usz i; for (i=0; i