From dabd29f2b289e55ad2740ec4e4b22385fef72018 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 11 Mar 2023 22:25:21 -0600 Subject: [PATCH] fix: std::clamp() assertion failure in maxAvailableReqs() (#5203) --- libtransmission/peer-msgs.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libtransmission/peer-msgs.cc b/libtransmission/peer-msgs.cc index d15ada5a3..aa5db6615 100644 --- a/libtransmission/peer-msgs.cc +++ b/libtransmission/peer-msgs.cc @@ -619,7 +619,11 @@ private: size_t constexpr Seconds = RequestBufSecs; size_t const estimated_blocks_in_period = (rate_bytes_per_second * Seconds) / tr_block_info::BlockSize; size_t const ceil = reqq ? *reqq : 250; - return std::clamp(estimated_blocks_in_period, Floor, ceil); + + auto max_reqs = estimated_blocks_in_period; + max_reqs = std::min(max_reqs, ceil); + max_reqs = std::max(max_reqs, Floor); + return max_reqs; } void protocolSendRequest(struct peer_request const& req)