diff --git a/asio/src/examples/cpp14/operations/composed_6.cpp b/asio/src/examples/cpp14/operations/composed_6.cpp index 82c0cd7223..b056272b76 100644 --- a/asio/src/examples/cpp14/operations/composed_6.cpp +++ b/asio/src/examples/cpp14/operations/composed_6.cpp @@ -156,9 +156,10 @@ auto async_write_messages(tcp::socket& socket, // We no longer have any future work coming for the I/O executor. io_work_.reset(); - // Deallocate the encoded message before calling the user-supplied - // completion handler. + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. encoded_message_.reset(); + delay_timer_.reset(); // Call the user-supplied handler with the result of the operation. handler_(error); diff --git a/asio/src/examples/cpp20/operations/composed_6.cpp b/asio/src/examples/cpp20/operations/composed_6.cpp index 77e2f50f93..da89886d55 100644 --- a/asio/src/examples/cpp20/operations/composed_6.cpp +++ b/asio/src/examples/cpp20/operations/composed_6.cpp @@ -161,9 +161,10 @@ auto async_write_messages(tcp::socket& socket, // We no longer have any future work coming for the I/O executor. io_work_.reset(); - // Deallocate the encoded message before calling the user-supplied - // completion handler. + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. encoded_message_.reset(); + delay_timer_.reset(); // Call the user-supplied handler with the result of the operation. handler_(error);