diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index f1857f5cfc..b0162f55f3 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -978,6 +978,9 @@ class GenericValue { bool IsLosslessFloat() const { if (!IsNumber()) return false; double a = GetDouble(); + if (a < static_cast(-std::numeric_limits::max()) + || a > static_cast(std::numeric_limits::max())) + return false; double b = static_cast(static_cast(a)); return a >= b && a <= b; // Prevent -Wfloat-equal }