From a034eeed23aa7dc86f95e713c4b1e5332bc4a407 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 19 Jul 2017 15:26:29 -0400 Subject: [PATCH] Have parse of %p set failbit if unsuccessful. --- date.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/date.h b/date.h index 753e991..7ed8a5f 100644 --- a/date.h +++ b/date.h @@ -5845,14 +5845,14 @@ from_stream(std::basic_istream& is, const CharT* fmt, { if (I == not_a_hour_12_value) goto broken; + tm = std::tm{}; tm.tm_hour = I; ios_base::iostate err = ios_base::goodbit; f.get(is, 0, is, err, &tm, command, fmt+1); - if (!(err & ios::failbit)) - { - h = hours{tm.tm_hour}; - I = not_a_hour_12_value; - } + if (err & ios::failbit) + goto broken; + h = hours{tm.tm_hour}; + I = not_a_hour_12_value; } else read(is, CharT{'%'}, width, modified, *fmt);