diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 788eb8da..7d6aeb2a 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -1153,8 +1153,8 @@ int snprintf_float(T value, int precision, float_specs specs, auto capacity = buf.capacity() - offset; #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if (precision > 100000) - throw std::runtime_error( - "fuzz mode - avoid large allocation inside snprintf"); + FMT_THROW(std::runtime_error( + "fuzz mode - avoid large allocation inside snprintf")); #endif // Suppress the warning about a nonliteral format string. // Cannot use auto becase of a bug in MinGW (#1532). diff --git a/include/fmt/format.h b/include/fmt/format.h index 6b43aeac..f6054b74 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -700,7 +700,7 @@ class basic_memory_buffer : public internal::buffer { template void basic_memory_buffer::grow(std::size_t size) { #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much"); + if (size > 1000) FMT_THROW(std::runtime_error("fuzz mode - won't grow that much")); #endif std::size_t old_capacity = this->capacity(); std::size_t new_capacity = old_capacity + old_capacity / 2; @@ -1138,7 +1138,7 @@ template class float_writer { } #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if (num_zeros > 1000) - throw std::runtime_error("fuzz mode - avoiding excessive cpu use"); + FMT_THROW(std::runtime_error("fuzz mode - avoiding excessive cpu use")); #endif it = std::fill_n(it, num_zeros, static_cast('0')); } diff --git a/src/format.cc b/src/format.cc index 680e6714..1f2dabf3 100644 --- a/src/format.cc +++ b/src/format.cc @@ -15,8 +15,8 @@ int format_float(char* buf, std::size_t size, const char* format, int precision, T value) { #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if (precision > 100000) - throw std::runtime_error( - "fuzz mode - avoid large allocation inside snprintf"); + FMT_THROW(std::runtime_error( + "fuzz mode - avoid large allocation inside snprintf")); #endif // Suppress the warning about nonliteral format string. int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF; diff --git a/test/fuzzing/README.md b/test/fuzzing/README.md index 0499d00c..d8e20849 100644 --- a/test/fuzzing/README.md +++ b/test/fuzzing/README.md @@ -9,7 +9,7 @@ resource exhaustion: ```cpp #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION if(spec.precision>100000) { - throw std::runtime_error("fuzz mode - avoiding large precision"); + FMT_THROW(std::runtime_error("fuzz mode - avoiding large precision")); } #endif ```