
While investigating basic_path::append (please see my previous posts), I found something a bit suspect. template<class String, class Traits> template <class InputIterator> basic_path<String, Traits> & basic_path<String, Traits>::append( InputIterator first, InputIterator last ) { if ( detail::is_separator<path_type>( *first ) && detail::is_separator<path_type>( *(first+1) ) && *(first+2) == colon<path_type>::value ) first += 3; What if first == last? Worse, what if 'last' is the typical past-the-end (dereferencing undefined) value? Consider the following test-cases: -------------- path_test.cpp.patch -------------------- *** path_test.cpp.orig Fri Jan 13 20:39:08 2006 --- path_test.cpp Fri Jan 13 20:26:19 2006 *************** *** 12,17 **** --- 12,18 ---- #include <iostream> #include <sstream> #include <string> + #include <vector> #include <cstring> #include <cassert> *************** *** 251,256 **** --- 252,269 ---- PATH_CHECK( p5, bf ); p5.append( bf, bf + sizeof(bf) ); PATH_CHECK( p5, "bar/foo/bar/foo" ); + + std::string s1( "//:somestring" ); + std::vector<char> v1( s1.begin(), s1.end() ); + v1.resize( 0 ); + + p5.assign( v1.begin(), v1.end() ); + std::string s2( v1.begin(), v1.end() ); + PATH_CHECK( p5, s2 ); + + p5.assign( s1.begin(), s1.begin() + 1 ); + PATH_CHECK( p5, "/" ); + # endif BOOST_CHECK( p1 != p4 ); ------------- end path_test.cpp.patch -----------------