mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 11:17:35 +02:00
Make ubsan happy on empty format specs (#2175)
This commit is contained in:
@ -3525,11 +3525,13 @@ struct formatter<T, Char,
|
|||||||
// terminating '}'.
|
// terminating '}'.
|
||||||
template <typename ParseContext>
|
template <typename ParseContext>
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||||
|
auto begin = ctx.begin(), end = ctx.end();
|
||||||
|
if (begin == end) return begin;
|
||||||
using handler_type = detail::dynamic_specs_handler<ParseContext>;
|
using handler_type = detail::dynamic_specs_handler<ParseContext>;
|
||||||
auto type = detail::type_constant<T, Char>::value;
|
auto type = detail::type_constant<T, Char>::value;
|
||||||
detail::specs_checker<handler_type> handler(handler_type(specs_, ctx),
|
detail::specs_checker<handler_type> handler(handler_type(specs_, ctx),
|
||||||
type);
|
type);
|
||||||
auto it = parse_format_specs(ctx.begin(), ctx.end(), handler);
|
auto it = parse_format_specs(begin, end, handler);
|
||||||
auto eh = ctx.error_handler();
|
auto eh = ctx.error_handler();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case detail::type::none_type:
|
case detail::type::none_type:
|
||||||
|
Reference in New Issue
Block a user