Skip to content

Commit 2495fd6

Browse files
committed
Change position of iterator advancement and throw on wrong end
1 parent 303fdd8 commit 2495fd6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/boost/decimal/fmt_format.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ constexpr auto parse_impl(ParseContext &ctx)
9999
BOOST_DECIMAL_THROW_EXCEPTION(std::logic_error("Invalid format specifier"));
100100
// LCOV_EXCL_STOP
101101
}
102+
++it;
102103
}
103104

104-
++it;
105+
// Verify we're at the closing brace
106+
if (it != ctx.end() && *it != '}')
107+
{
108+
BOOST_DECIMAL_THROW_EXCEPTION(std::logic_error("Expected '}' in format string")); // LCOV_EXCL_LINE
109+
}
105110

106111
return std::make_tuple(ctx_precision, fmt, is_upper, padding_digits, it);
107112
}

include/boost/decimal/format.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ constexpr auto parse_impl(ParseContext &ctx)
9595
BOOST_DECIMAL_THROW_EXCEPTION(std::format_error("Invalid format specifier"));
9696
// LCOV_EXCL_STOP
9797
}
98+
++it;
9899
}
99100

100-
++it;
101+
// Verify we're at the closing brace
102+
if (it != ctx.end() && *it != '}')
103+
{
104+
BOOST_DECIMAL_THROW_EXCEPTION(std::format_error("Expected '}' in format string")); // LCOV_EXCL_LINE
105+
}
101106

102107
return std::make_tuple(ctx_precision, fmt, is_upper, padding_digits, it);
103108
}

0 commit comments

Comments
 (0)