diff options
| author | Mikael Persson <mikael.s.persson@gmail.com> | 2025-06-10 20:45:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-11 03:45:26 +0300 |
| commit | 708fff700f36ab3c2ab107b984ec9f3b8be5f055 (patch) | |
| tree | f485a3e4efb06de2d00239ec9097896eca04d1ef | |
| parent | 2f35c28a52fd0ada7600273de9aacb66550bcdcb (diff) | |
| download | Project-Tick-708fff700f36ab3c2ab107b984ec9f3b8be5f055.tar.gz Project-Tick-708fff700f36ab3c2ab107b984ec9f3b8be5f055.zip | |
Fixed undefined behavior with log10 cast of fractional doubles (#276)
| -rw-r--r-- | include/toml++/impl/toml_formatter.inl | 2 | ||||
| -rw-r--r-- | toml.hpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/include/toml++/impl/toml_formatter.inl b/include/toml++/impl/toml_formatter.inl index 201de9ce9e..8b4f633dca 100644 --- a/include/toml++/impl/toml_formatter.inl +++ b/include/toml++/impl/toml_formatter.inl @@ -91,7 +91,7 @@ TOML_ANON_NAMESPACE_START weight += 1u; val *= -1.0; } - return weight + static_cast<size_t>(log10(val)) + 1u; + return weight + static_cast<size_t>(abs(log10(val))) + 1u; } case node_type::boolean: return 5u; @@ -17107,7 +17107,7 @@ TOML_ANON_NAMESPACE_START weight += 1u; val *= -1.0; } - return weight + static_cast<size_t>(log10(val)) + 1u; + return weight + static_cast<size_t>(abs(log10(val))) + 1u; } case node_type::boolean: return 5u; |
