From e0e68c7c9db1da2d2e285ef06c91a01cfa159c44 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Fri, 7 Feb 2025 12:36:02 +0900 Subject: [PATCH] Stored range.size() before forwarding range. Fixed #1582 --- asio/include/asio/experimental/impl/parallel_group.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asio/include/asio/experimental/impl/parallel_group.hpp b/asio/include/asio/experimental/impl/parallel_group.hpp index 75e8a15187..d11ddaee4c 100644 --- a/asio/include/asio/experimental/impl/parallel_group.hpp +++ b/asio/include/asio/experimental/impl/parallel_group.hpp @@ -706,6 +706,7 @@ void ranged_parallel_group_launch(Condition cancellation_condition, std::move(handler), range.size(), allocator); std::size_t idx = 0; + std::size_t range_size = range.size(); for (auto&& op : std::forward(range)) { typedef associated_executor_t ex_type; @@ -718,7 +719,7 @@ void ranged_parallel_group_launch(Condition cancellation_condition, // Check if any of the operations has already requested cancellation, and if // so, emit a signal for each operation in the group. - if ((state->cancellations_requested_ -= range.size()) > 0) + if ((state->cancellations_requested_ -= range_size) > 0) for (auto& signal : state->cancellation_signals_) signal.emit(state->cancel_type_);