Don't assume nul termination in printf

Thanks ZUENS2020 for reporting.
This commit is contained in:
Victor Zverovich
2026-03-23 09:22:38 -07:00
parent ea85b81ccd
commit dc05bee307
4 changed files with 13 additions and 19 deletions

View File

@@ -330,6 +330,7 @@ template <typename Char, typename GetArg>
auto parse_header(const Char*& it, const Char* end, format_specs& specs,
GetArg get_arg) -> int {
int arg_index = -1;
if (it == end) return arg_index;
Char c = *it;
if (c >= '0' && c <= '9') {
// Parse an argument index (if followed by '$') or a width possibly