diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2025-03-30 23:08:43 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2025-03-30 23:08:43 -0500 |
commit | cb9fa588ba8144fcdd52ba4b83d69d93fb18066f (patch) | |
tree | 214574ca68c1551ec76e7fbb9e0263793180231d /include/fud_format.hpp | |
parent | 1d357adfa19725ee69fb267a363f1fd217b1272f (diff) |
Add hash map.
Diffstat (limited to 'include/fud_format.hpp')
-rw-r--r-- | include/fud_format.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/fud_format.hpp b/include/fud_format.hpp index e80d96e..0dff3c1 100644 --- a/include/fud_format.hpp +++ b/include/fud_format.hpp @@ -261,6 +261,9 @@ struct FormatArguments { template <typename... Args> static auto makeFormatArguments(Args&&... args) -> FormatArguments { + static_assert(Size == sizeof...(Args)); + constexpr size_t MaxStackFormatArgSize = 2048U; + static_assert(sizeof(FormatArguments) < MaxStackFormatArgSize); return FormatArguments{Array<FormatArgument, Size>{{FormatArgument{std::forward<Args>(args)}...}}}; } }; @@ -440,6 +443,10 @@ FormatResult vFormat(Sink& sink, FormatCharMode formatMode, FormatString fmt, co } formatArgIndex = formatSpec.position; } + if (formatArgIndex >= Size) { + result.status = FudStatus::FormatInvalid; + return result; + } auto argResult{std::visit( [&](const auto& arg) -> FormatResult { return format(sink, formatMode, formatSpec, arg); }, args[formatArgIndex])}; @@ -451,7 +458,6 @@ FormatResult vFormat(Sink& sink, FormatCharMode formatMode, FormatString fmt, co if (!formatSpec.takesPosition()) { argIndex++; argIndex += static_cast<uint8_t>(formatSpec.takesWidth); - argIndex += static_cast<uint8_t>(formatSpec.takesPrecision); } } |