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
This commit is contained in:
Gaurav 2014-11-17 14:04:03 +05:30
parent 3e3a8d5bd2
commit 767713be2b

View File

@ -831,8 +831,9 @@ std::vector<Reader::StructuredError> 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;