Don't touch begin iterator (pointer) if begin == end.

Fixes #2661.
This commit is contained in:
David P. Sicilia 2021-12-17 11:50:25 -05:00
parent 35f60377aa
commit e98129ec38

View File

@ -2482,6 +2482,8 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(const Char* begin,
const Char* end, const Char* end,
SpecHandler&& handler) SpecHandler&& handler)
-> const Char* { -> const Char* {
if (begin == end) return begin;
if (begin + 1 < end && begin[1] == '}' && is_ascii_letter(*begin) && if (begin + 1 < end && begin[1] == '}' && is_ascii_letter(*begin) &&
*begin != 'L') { *begin != 'L') {
presentation_type type = parse_presentation_type(*begin++); presentation_type type = parse_presentation_type(*begin++);
@ -2491,8 +2493,6 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(const Char* begin,
return begin; return begin;
} }
if (begin == end) return begin;
begin = parse_align(begin, end, handler); begin = parse_align(begin, end, handler);
if (begin == end) return begin; if (begin == end) return begin;