BewareMyPower opened a new pull request, #362:
URL: https://github.com/apache/pulsar-client-cpp/pull/362

   Fixes https://github.com/apache/pulsar-client-cpp/issues/358 Fixes 
https://github.com/apache/pulsar-client-cpp/issues/359
   
   ### Motivation
   
   `async_wait` is not used correctly in some places. A callback that captures 
the `this` pointer or reference to `this` is passed to `async_wait`, if this 
object is destroyed when the callback is called, an invalid memory access will 
happen.
   
   ### Modifications
   
   Use the following pattern in all `async_wait` calls.
   
   ```c++
   std::weak_ptr<T> weakSelf{shared_from_this()};
   timer_->async_wait([weakSelf](/* ... */) {
       if (auto self = weakSelf.lock()) {
           self->foo();
       }
   });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to