From c2754e0fff6c4b2fa29013059560c2fe32ba6975 Mon Sep 17 00:00:00 2001 From: dzaima Date: Mon, 17 Apr 2023 12:53:02 +0300 Subject: [PATCH] =?UTF-8?q?don't=20OOM=20in=20=F0=9D=95=A8=E2=86=91?= =?UTF-8?q?=F0=9D=95=A9=20with=200=E2=89=A1=C3=97=C2=B4=F0=9D=95=A8=20if?= =?UTF-8?q?=20product=20of=20prefix=20overflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/sfns.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index c42ae3cc..b72c18b1 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -495,6 +495,8 @@ NOINLINE B takedrop_highrank(bool take, B w, B x) { usz ria = 1; bool anyFill = false; i64 cellStart = -1; // axis from which whole cells can be copied + bool overflow = false; + bool anyZero = false; for (usz i = 0; i < rr; i++) { i64 cw = ixshc; rsh->a[i] = c; - if (mulOn(ria, c)) thrOOM(); + if (c==0) anyZero = true; + if (mulOn(ria, c)) overflow = true; + } + if (overflow) { + if (!anyZero) thrOOM(); + ria = 0; } CHECK_IA(ria, 8);