Skip to content

Commit 18f3edd

Browse files
maxkozlovskyjhunsaker
authored andcommitted
Fix duplicate update of within_completion_count after move construct
Clear parent pointer in moved out object to prevent decrementing within_completion_count twice.
1 parent 23444ad commit 18f3edd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

category/async/io.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,16 @@ namespace detail
9898
}
9999

100100
within_completions_holder(within_completions_holder const &) = delete;
101-
within_completions_holder(within_completions_holder &&) = default;
101+
102+
within_completions_holder(within_completions_holder &&other) noexcept
103+
: parent(other.parent)
104+
{
105+
other.parent = nullptr;
106+
}
102107

103108
~within_completions_holder()
104109
{
105-
if (0 == --parent->within_completions_count) {
110+
if (parent && 0 == --parent->within_completions_count) {
106111
parent->within_completions_reached_zero();
107112
}
108113
}

0 commit comments

Comments
 (0)