From 691415a656ebe32c529c027e45c7560f69ec9d2f Mon Sep 17 00:00:00 2001 From: "S. Lebedev" Date: Tue, 1 Aug 2023 13:42:16 +0200 Subject: [PATCH] Add ill-defined parameters check. --- include/node.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/node.hpp b/include/node.hpp index c1d7e6158..67ffd9832 100644 --- a/include/node.hpp +++ b/include/node.hpp @@ -613,6 +613,12 @@ class node : protected std::tuple { } if (numerator != 1. || denominator != 1.) { + bool is_ill_defined = (denominator > ports_status.in_max_samples); + assert(!is_ill_defined); + if (is_ill_defined) { + return { requested_work, 0_UZ, work_return_status_t::ERROR }; + } + ports_status.in_samples = static_cast(ports_status.in_samples / denominator) * denominator; // remove reminder const std::size_t out_min_limit = ports_status.out_min_samples; @@ -627,7 +633,6 @@ class node : protected std::tuple { std::size_t in_max_wo_reminder = static_cast(in_max_samples / denominator) * denominator; if (ports_status.in_samples < in_min_wo_reminder) return { requested_work, 0_UZ, work_return_status_t::INSUFFICIENT_INPUT_ITEMS }; - ports_status.in_samples = std::clamp(ports_status.in_samples, in_min_wo_reminder, in_max_wo_reminder); ports_status.out_samples = numerator * (ports_status.in_samples / denominator); }