bug 280386: Add sanity checking to nsScanner::SetPosition to help catch errors that could manifest in stranger ways. r=bzbarsky sr=jst

This commit is contained in:
mrbkap%gmail.com 2005-02-02 02:04:09 +00:00
Родитель 69c36c7a88
Коммит cbd3d9f468
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -1346,12 +1346,22 @@ void nsScanner::EndReading(nsScannerIterator& aPosition)
void nsScanner::SetPosition(nsScannerIterator& aPosition, PRBool aTerminate, PRBool aReverse)
{
if (mSlidingBuffer) {
#ifdef DEBUG
PRUint32 origRemaining = mCountRemaining;
#endif
if (aReverse) {
mCountRemaining += (Distance(aPosition, mCurrentPosition));
}
else {
mCountRemaining -= (Distance(mCurrentPosition, aPosition));
}
NS_ASSERTION((mCountRemaining >= origRemaining && aReverse) ||
(mCountRemaining <= origRemaining && !aReverse),
"Improper use of nsScanner::SetPosition. Make sure to set the"
" aReverse parameter correctly");
mCurrentPosition = aPosition;
if (aTerminate && (mCurrentPosition == mEndPosition)) {
mMarkPosition = mCurrentPosition;