зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
69c36c7a88
Коммит
cbd3d9f468
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче