use FMT_THROW
Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
parent
6f435f55c8
commit
9aa1517525
@ -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).
|
||||
|
||||
@ -700,7 +700,7 @@ class basic_memory_buffer : public internal::buffer<T> {
|
||||
template <typename T, std::size_t SIZE, typename Allocator>
|
||||
void basic_memory_buffer<T, SIZE, Allocator>::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 <typename Char> 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<Char>('0'));
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user