Don't assume nul termination in printf

Thanks ZUENS2020 for reporting.
This commit is contained in:
Victor Zverovich
2026-03-23 13:28:26 -07:00
parent ea85b81ccd
commit dc05bee307
4 changed files with 13 additions and 19 deletions
-16
View File
@@ -268,22 +268,6 @@ TEST(util_test, format_system_error) {
fmt::format_system_error(message, EDOM, "test");
auto ec = std::error_code(EDOM, std::generic_category());
EXPECT_EQ(to_string(message), std::system_error(ec, "test").what());
message = fmt::memory_buffer();
// Check if std::allocator throws on allocating max size_t / 2 chars.
size_t max_size = max_value<size_t>() / 2;
bool throws_on_alloc = false;
try {
auto alloc = std::allocator<char>();
alloc.deallocate(alloc.allocate(max_size), max_size);
} catch (const std::bad_alloc&) {
throws_on_alloc = true;
}
if (!throws_on_alloc) {
fmt::print(stderr, "warning: std::allocator allocates {} chars\n",
max_size);
return;
}
}
TEST(util_test, system_error) {