From a8f522b5998fd1b6dc57ef785b0f3420122fcedd Mon Sep 17 00:00:00 2001 From: Marlene Cota Date: Mon, 29 Apr 2024 16:35:12 -0700 Subject: [PATCH 1/2] Fix CodeQL alert --- include/fmt/base.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 5acd3e648707..00de04af3d53 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1902,7 +1902,9 @@ template class basic_format_args { if (id >= detail::max_packed_args) return arg; arg.type_ = type(id); if (arg.type_ == detail::type::none_type) return arg; - arg.value_ = values_[id]; + if (id >= 0) { + arg.value_ = values_[id]; + } return arg; } From 58c6ecc091f75783bdfb1342a033483bd85206b8 Mon Sep 17 00:00:00 2001 From: Marlene Cota Date: Tue, 30 Apr 2024 11:12:57 -0700 Subject: [PATCH 2/2] static_cast(id) --- include/fmt/base.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 00de04af3d53..772bc02ab9f0 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1899,12 +1899,10 @@ template class basic_format_args { if (id < max_size()) arg = args_[id]; return arg; } - if (id >= detail::max_packed_args) return arg; + if (static_cast(id) >= detail::max_packed_args) return arg; arg.type_ = type(id); if (arg.type_ == detail::type::none_type) return arg; - if (id >= 0) { - arg.value_ = values_[id]; - } + arg.value_ = values_[id]; return arg; }