mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #328 from Vhuynh25/master
Ignore NaN and infinite values in json::wvalue
This commit is contained in:
commit
e8e46266b3
@ -16,9 +16,11 @@
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
|
||||
#include "crow/settings.h"
|
||||
#include "crow/returnable.h"
|
||||
#include "crow/logging.h"
|
||||
|
||||
#if defined(__GNUG__) || defined(__clang__)
|
||||
#define crow_json_likely(x) __builtin_expect(x, 1)
|
||||
@ -1772,6 +1774,12 @@ namespace crow
|
||||
{
|
||||
if (v.nt == num_type::Floating_point)
|
||||
{
|
||||
if (isnan(v.num.d) || isinf(v.num.d))
|
||||
{
|
||||
out += "null";
|
||||
CROW_LOG_WARNING << "Invalid JSON value detected (" << v.num.d << "), value set to null";
|
||||
break;
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
#define MSC_COMPATIBLE_SPRINTF(BUFFER_PTR, FORMAT_PTR, VALUE) sprintf_s((BUFFER_PTR), 128, (FORMAT_PTR), (VALUE))
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user