Merge pull request #3518 from SChernykh/dev

Make Json::normalize more strict
This commit is contained in:
xmrig 2024-07-29 22:27:29 +07:00 committed by GitHub
commit b4a47d6ed0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,11 +211,13 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
{
using namespace rapidjson;
if (!std::isnormal(value)) {
const double value_rounded = floor(value * 100.0) / 100.0;
if (!std::isnormal(value) || !std::isnormal(value_rounded)) {
return zero ? Value(0.0) : Value(kNullType);
}
return Value(floor(value * 100.0) / 100.0);
return Value(value_rounded);
}