From b72309436dfd8385d94a74453a1f57cc27f20b88 Mon Sep 17 00:00:00 2001 From: Shawn Zhong Date: Sat, 14 Jan 2023 01:23:44 -0600 Subject: [PATCH] Fix potential buffer overflow --- include/fmt/chrono.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index d3a9ec59c2c92..cf362f69bb063 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -705,8 +705,9 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, continue; } if (begin != ptr) handler.on_text(begin, ptr); - c = *++ptr; // consume '%' + ++ptr; // consume '%' if (ptr == end) FMT_THROW(format_error("invalid format")); + c = *ptr; switch (c) { case '_': pad = pad_type::space;