From 7ca5851f785ef6613706b7c593554b4fc94c853b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 16 Dec 2016 08:05:29 +0100 Subject: [PATCH] - fixed a second spot in RapidJSON where a bad NaN check was done. --- src/rapidjson/writer.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rapidjson/writer.h b/src/rapidjson/writer.h index a8eeab66d..a288f07ff 100644 --- a/src/rapidjson/writer.h +++ b/src/rapidjson/writer.h @@ -524,8 +524,13 @@ template<> inline bool Writer::WriteDouble(double d) { if (internal::Double(d).IsNanOrInf()) { // Note: This code path can only be reached if (RAPIDJSON_WRITE_DEFAULT_FLAGS & kWriteNanAndInfFlag). - if (!(kWriteDefaultFlags & kWriteNanAndInfFlag)) - return false; + if (!(kWriteDefaultFlags & kWriteNanAndInfFlag)) + { + // At least ensure that the output does not get broken. + PutReserve(*os_, 1); + PutUnsafe(*os_, '0'); + return false; + } if (internal::Double(d).IsNan()) { PutReserve(*os_, 3); PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');