From e98129ec38cd3841489ebcfbf4852c0b584ddc23 Mon Sep 17 00:00:00 2001 From: "David P. Sicilia" Date: Fri, 17 Dec 2021 11:50:25 -0500 Subject: [PATCH] Don't touch begin iterator (pointer) if begin == end. Fixes #2661. --- include/fmt/core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 9e0e8964575c..a9fa54b8da60 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2482,6 +2482,8 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(const Char* begin, const Char* end, SpecHandler&& handler) -> const Char* { + if (begin == end) return begin; + if (begin + 1 < end && begin[1] == '}' && is_ascii_letter(*begin) && *begin != 'L') { presentation_type type = parse_presentation_type(*begin++); @@ -2491,8 +2493,6 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(const Char* begin, return begin; } - if (begin == end) return begin; - begin = parse_align(begin, end, handler); if (begin == end) return begin;