Universal fix for NaN and Infinity in JSON output

This commit is contained in:
XMRig 2025-06-06 14:36:21 +07:00
parent 184d6100dc
commit 682834b87d
No known key found for this signature in database
GPG key ID: 446A53638BE94409
2 changed files with 11 additions and 3 deletions

View file

@ -29,6 +29,8 @@ else()
set(WITH_VAES OFF) set(WITH_VAES OFF)
endif() endif()
add_definitions(-DRAPIDJSON_WRITE_DEFAULT_FLAGS=6) # rapidjson::kWriteNanAndInfFlag | rapidjson::kWriteNanAndInfNullFlag
if (ARM_V8) if (ARM_V8)
set(ARM_TARGET 8) set(ARM_TARGET 8)
elseif (ARM_V7) elseif (ARM_V7)

View file

@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2025 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@
#include "base/tools/Chrono.h" #include "base/tools/Chrono.h"
#include "base/tools/Cvt.h" #include "base/tools/Cvt.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "rapidjson/writer.h"
#include "version.h" #include "version.h"
@ -46,6 +46,12 @@
namespace xmrig { namespace xmrig {
static_assert(
RAPIDJSON_WRITE_DEFAULT_FLAGS == (rapidjson::kWriteNanAndInfFlag | rapidjson::kWriteNanAndInfNullFlag),
"(rapidjson::kWriteNanAndInfFlag | rapidjson::kWriteNanAndInfNullFlag) required"
);
static rapidjson::Value getResources(rapidjson::Document &doc) static rapidjson::Value getResources(rapidjson::Document &doc)
{ {
using namespace rapidjson; using namespace rapidjson;