From c8673ef3de075e486f8159c6ed0dd7f5e2595619 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 3 Jul 2014 17:05:03 +0200 Subject: [PATCH] GenericReader::ParseNumber: consistently use s.Tell() The error messages in ParseNumber used `is.Tell` to report the position of the number parsing error. Depending on the copy optimization of the current stream, this can lead to different behaviour (beginning of number vs. position of error). --- include/rapidjson/reader.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 19b906d..9010aec 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -610,7 +610,7 @@ private: } } else - RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell()); // Parse 64bit int uint64_t i64 = 0; @@ -643,7 +643,7 @@ private: d = (double)i64; while (s.Peek() >= '0' && s.Peek() <= '9') { if (d >= 1E307) - RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); d = d * 10 + (s.Take() - '0'); } } @@ -662,7 +662,7 @@ private: --expFrac; } else - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, s.Tell()); while (s.Peek() >= '0' && s.Peek() <= '9') { if (expFrac > -16) { @@ -695,11 +695,11 @@ private: while (s.Peek() >= '0' && s.Peek() <= '9') { exp = exp * 10 + (s.Take() - '0'); if (exp > 308) - RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); } } else - RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, is.Tell()); + RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, s.Tell()); if (expMinus) exp = -exp;