Fixed behavior change of ByteVector::containsAt()

This commit is contained in:
Tsuda Kageyu 2013-06-02 03:45:13 +09:00
parent df5bf232eb
commit 860a605c8d

View File

@ -601,11 +601,11 @@ bool ByteVector::containsAt(const ByteVector &pattern, uint offset, uint pattern
patternLength = pattern.size();
// do some sanity checking -- all of these things are needed for the search to be valid
if(offset + patternLength > size() || patternOffset >= pattern.size() || patternLength == 0)
const uint compareLength = patternLength - patternOffset;
if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0)
return false;
return (::memcmp(data() + offset, pattern.data() + patternOffset, patternLength - patternOffset) == 0);
return (::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0);
}
bool ByteVector::startsWith(const ByteVector &pattern) const