Don't assume nul termination in printf
Thanks ZUENS2020 for reporting.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user