Boost logo

Boost :

Subject: [boost] bug in boost::asio
From: puzirev_at_[hidden]
Date: 2009-05-28 15:44:44


Wrong allocation of timer in timer_queue.hpp:

template <typename Handler>
bool enqueue_timer(const time_type& time, Handler handler, void* token)
{
   // Ensure that there is space for the timer in the heap. We reserve
here so
   // that the push_back below will not throw due to a reallocation
failure.
   heap_.reserve(heap_.size() + 1);

   // Create a new timer object.
   std::auto_ptr<timer<Handler> > new_timer(
       new timer<Handler>(time, handler, token)); // <-- ATTENTION
...
new timer<Handler>(...) later will be dealocated with
asio_handler_deallocate
Solution: allocate new timers with asio_handler_allocate
   // Create a new timer object.
   typedef timer<Handler> timer_type;
   typedef handler_alloc_traits<Handler, timer_type> alloc_traits;
   raw_handler_ptr<alloc_traits> raw_ptr(handler);
   handler_ptr<alloc_traits> new_timer(raw_ptr, time, handler, token);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk