From 112e747d935404ebbea2225b076cc5fd6db636f7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 30 Jul 2012 15:01:15 -0700 Subject: [PATCH] Avoid inserting 'inf' and friends into the json output. The JSON-generating code was previously carefult to avoid emitting NaN into its output, but it would still write "inf" for an infinite value, (which is invalid JSON). Fix by calling writeNull for any value for which std::isfinite returns false, (rather than the previous test for merely (n != n)). --- retrace/json.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/retrace/json.hpp b/retrace/json.hpp index 6af1f4c..2f50a8c 100644 --- a/retrace/json.hpp +++ b/retrace/json.hpp @@ -34,6 +34,13 @@ #include #include +#ifdef _MSC_VER +# include +# define isfinite _finite +#else +# include // isfinite +#endif + #include #include #include @@ -328,8 +335,8 @@ public: template inline void writeNumber(T n) { - if (n != n) { - // NaN + if (!isfinite(n)) { + // NaN/Inf writeNull(); } else { separator(); -- 2.43.0