|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86230 - in trunk: boost/date_time libs/date_time/test/gregorian
From: marshall_at_[hidden]
Date: 2013-10-10 11:43:31
Author: marshall
Date: 2013-10-10 11:43:31 EDT (Thu, 10 Oct 2013)
New Revision: 86230
URL: http://svn.boost.org/trac/boost/changeset/86230
Log:
Fix several 'iterating past the end' bugs in Boost.DateTime; Refs #9216
Text files modified:
trunk/boost/date_time/format_date_parser.hpp | 12 ++++++++----
trunk/boost/date_time/time_facet.hpp | 4 ++--
trunk/libs/date_time/test/gregorian/testdate_input_facet.cpp | 5 +++++
3 files changed, 15 insertions(+), 6 deletions(-)
Modified: trunk/boost/date_time/format_date_parser.hpp
==============================================================================
--- trunk/boost/date_time/format_date_parser.hpp Thu Oct 10 11:40:07 2013 (r86229)
+++ trunk/boost/date_time/format_date_parser.hpp 2013-10-10 11:43:31 EDT (Thu, 10 Oct 2013) (r86230)
@@ -271,7 +271,8 @@
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'a':
@@ -476,7 +477,8 @@
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'b':
@@ -577,7 +579,8 @@
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'a':
@@ -666,7 +669,8 @@
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
//match_results mr;
switch(*itr) {
Modified: trunk/boost/date_time/time_facet.hpp
==============================================================================
--- trunk/boost/date_time/time_facet.hpp Thu Oct 10 11:40:07 2013 (r86229)
+++ trunk/boost/date_time/time_facet.hpp 2013-10-10 11:43:31 EDT (Thu, 10 Oct 2013) (r86230)
@@ -816,7 +816,7 @@
const_itr itr(m_time_duration_format.begin());
while (itr != m_time_duration_format.end() && (sitr != stream_end)) {
if (*itr == '%') {
- ++itr;
+ if (++itr == m_time_duration_format.end()) break;
if (*itr != '%') {
switch(*itr) {
case 'O':
@@ -988,7 +988,7 @@
const_itr itr(this->m_format.begin());
while (itr != this->m_format.end() && (sitr != stream_end)) {
if (*itr == '%') {
- ++itr;
+ if (++itr == this->m_format.end()) break;
if (*itr != '%') {
// the cases are grouped by date & time flags - not alphabetical order
switch(*itr) {
Modified: trunk/libs/date_time/test/gregorian/testdate_input_facet.cpp
==============================================================================
--- trunk/libs/date_time/test/gregorian/testdate_input_facet.cpp Thu Oct 10 11:40:07 2013 (r86229)
+++ trunk/libs/date_time/test/gregorian/testdate_input_facet.cpp 2013-10-10 11:43:31 EDT (Thu, 10 Oct 2013) (r86230)
@@ -212,6 +212,11 @@
ss.str("%2005");
ss >> y;
check_equal("Multiple literal '%'s in year format", y, greg_year(2005));
+
+ f->year_format("%Y%");
+ ss.str("2005%");
+ ss >> y;
+ check_equal("Trailing'%'s in year format", y, greg_year(2005));
}
// All days, month, weekday, day, and year formats have been tested
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk