From f2c9cb6244b7c162532528ec1613f1f2fa476023 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 8 Jun 2020 06:32:11 -0700 Subject: [PATCH] Fix a UB --- include/fmt/format.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index d6857413..79f39b8d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2550,7 +2550,11 @@ struct format_handler : detail::error_handler { int on_arg_id() { return parse_context.next_arg_id(); } int on_arg_id(int id) { return parse_context.check_arg_id(id), id; } - int on_arg_id(basic_string_view id) { return context.arg_id(id); } + int on_arg_id(basic_string_view id) { + int arg_id = context.arg_id(id); + if (arg_id < 0) on_error("argument not found"); + return arg_id; + } void on_replacement_field(int id, const Char* p) { auto arg = get_arg(context, id);