From 767713be2b647709cfba22334e6e4cb4ccd3bfaa Mon Sep 17 00:00:00 2001 From: Gaurav Date: Mon, 17 Nov 2014 14:04:03 +0530 Subject: [PATCH] Remove gcc compilation warning in json_reader.cpp Submitting Patch for Issue : https://github.com/open-source-parsers/jsoncpp/issues/77 It will fix warnings in json_reader.cpp --- src/lib_json/json_reader.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 1b2f187..c5111f8 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -831,8 +831,9 @@ std::vector Reader::getStructuredErrors() const { } bool Reader::pushError(const Value& value, const std::string& message) { - if(value.getOffsetStart() > end_ - begin_ - || value.getOffsetLimit() > end_ - begin_) + size_t length = end_ - begin_; + if(value.getOffsetStart() > length + || value.getOffsetLimit() > length) return false; Token token; token.type_ = tokenError; @@ -847,9 +848,10 @@ bool Reader::pushError(const Value& value, const std::string& message) { } bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) { - if(value.getOffsetStart() > end_ - begin_ - || value.getOffsetLimit() > end_ - begin_ - || extra.getOffsetLimit() > end_ - begin_) + size_t length = end_ - begin_; + if(value.getOffsetStart() > length + || value.getOffsetLimit() > length + || extra.getOffsetLimit() > length) return false; Token token; token.type_ = tokenError;