Opened 2 years ago

#12354 new Bugs

boost::asio::connect crash when connect_condition sets iterator to end

Reported by: snua12@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.60.0 Severity: Problem
Keywords: Cc:

Description

example:


auto getIPV4Only = [](const error_code& ec, iterator next) {
	resolver::iterator end;
	while (!ec && next != end) {
		if (next->endpoint().address().is_v4()) return next;
		++next;
	}
	return next;
};

connect(socket, iterator, getIPV4Only, ec); //<- crashes when getIPV4Only returns end

fix:

--- include/boost/asio/impl/connect.hpp (revision 1.6.0)
+++ include/boost/asio/impl/connect.hpp (working copy)
@@ -122,7 +122,9 @@
       s.connect(*iter, ec);
       if (!ec)
         return iter;
-    }
+       } else {
+               break;
+       }
   }

   if (!ec)


Change History (0)

Note: See TracTickets for help on using tickets.