From: Carl Worth Date: Mon, 30 Jul 2012 22:01:15 +0000 (-0700) Subject: Avoid inserting 'inf' and friends into the json output. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=112e747d935404ebbea2225b076cc5fd6db636f7;p=apitrace 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)). --- 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();