Opened 14 years ago

Closed 14 years ago

#2698 closed Bugs (fixed)

date-time library and checked iterators

Reported by: gast128@… Owned by: az_sw_dude
Milestone: Boost 1.38.0 Component: date_time
Version: Boost 1.37.0 Severity: Problem
Keywords: DateTime Cc:

Description

Dear all,

posted on the users group, I think the DateTime library contains a bug. When used with checked iterators, VStudio2008 stops the programming, because an illegal dereference.

the date_facet::do_put_tm contains the follwing line:

return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios, fill_char, &tm_value, &*a_format.begin(), &*a_format.begin()+a_format.size());

if the a_format is empty, dereferencing is illegal according too VStudio2008. Sample program:

#include <boost\date_time\gregorian\gregorian.hpp> #include <boost\date_time\posix_time\posix_time.hpp> #include <sstream>

int main() {

boost::gregorian::date date(2009, 1, 1); boost::posix_time::time_duration td(0, 0, 0, 0); boost::posix_time::ptime boost_time(date, td); std::stringstream sstr;

boost::posix_time::time_facet* pFacet = new boost::posix_time::time_facet(""); sstr.imbue(std::locale(std::locale::classic(), pFacet));

sstr << boost_time;

return 0;

}

Change History (1)

comment:1 by Andrey Semashev, 14 years ago

Resolution: fixed
Status: newclosed

(In [50877]) Removed dereferencing of end iterators of strings, which could cause crashes on MSVC. Fixed #2698.

Note: See TracTickets for help on using tickets.