]> granicus.if.org Git - taglib/commitdiff
Fixed behavior change of ByteVector::containsAt()
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 1 Jun 2013 18:45:13 +0000 (03:45 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 1 Jun 2013 18:45:13 +0000 (03:45 +0900)
taglib/toolkit/tbytevector.cpp

index ce47fbb856eb88d5c88b0be87b6765b11dd58248..631acc8774dc060148d55659cdd1713d176526c8 100644 (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