From: Tsuda Kageyu Date: Sat, 1 Jun 2013 18:45:13 +0000 (+0900) Subject: Fixed behavior change of ByteVector::containsAt() X-Git-Tag: v1.9~23^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=860a605c8d830e9ef83b64ce157bb4a2e2e40d29;p=taglib Fixed behavior change of ByteVector::containsAt() --- diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index ce47fbb8..631acc87 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -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