From 799ff26e71c03aec171fa0eb94abec8e11e3549e Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Mon, 15 Nov 2021 19:46:28 +0100 Subject: [PATCH] Avoid underflow when checking the length of `terms` --- src/util/reducing.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/reducing.rs b/src/util/reducing.rs index 1cddc3e7..f700a6ff 100644 --- a/src/util/reducing.rs +++ b/src/util/reducing.rs @@ -107,7 +107,7 @@ impl ReducingFactorTarget { let l = terms.len(); // For small reductions, use an arithmetic gate. - if l - 1 <= ArithmeticExtensionGate::::new_from_config(&builder.config).num_ops { + if l <= ArithmeticExtensionGate::::new_from_config(&builder.config).num_ops + 1 { let terms_ext = terms .iter() .map(|&t| builder.convert_to_ext(t)) @@ -162,7 +162,7 @@ impl ReducingFactorTarget { let l = terms.len(); // For small reductions, use an arithmetic gate. - if l - 1 <= ArithmeticExtensionGate::::new_from_config(&builder.config).num_ops { + if l <= ArithmeticExtensionGate::::new_from_config(&builder.config).num_ops + 1 { return self.reduce_arithmetic(terms, builder); }