From: Tsuda Kageyu Date: Wed, 17 Jul 2013 14:35:41 +0000 (+0900) Subject: Fixed an MSVC specific runtime error only in debug mode X-Git-Tag: v1.9~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89fcab5669013bd46b0ef7b7f6efbb8a21cd1ceb;p=taglib Fixed an MSVC specific runtime error only in debug mode --- diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 0ea7517c..ddc3d4f4 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -156,9 +156,8 @@ int findVector( for(size_t i = 0; i < patternSize - 1; ++i) lastOccurrence[static_cast(*(patternBegin + i))] = patternSize - i - 1; - for(TIterator it = dataBegin + patternSize - 1 + offset; - it < dataEnd; - it += lastOccurrence[static_cast(*it)]) + TIterator it = dataBegin + patternSize - 1 + offset; + while(true) { TIterator itBuffer = it; TIterator itPattern = patternBegin + patternSize - 1; @@ -176,6 +175,12 @@ int findVector( --itBuffer; --itPattern; } + + const size_t step = lastOccurrence[static_cast(*it)]; + if(dataEnd - step <= it) + break; + + it += step; } return -1;