Fix for an assert that has been bugging rods, particularly when testing with the top 100. The assert is the string |CharAt| out-of-range assert. The problem is the code was iterating off the end of the string to stop at the implicit |'\0'|. But there need not be null termination and accessing outside the strings defined range is bad. Fixed the loop in question to not step outside of the token string, and to iterate more efficiently. r=waterson

git-svn-id: svn://10.0.0.236/trunk@72259 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%mozilla.org
2000-06-15 00:39:21 +00:00
parent d5ebd0e9c7
commit 85ba05cab0
2 changed files with 20 additions and 18 deletions

View File

@@ -4104,16 +4104,17 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
while (!done && !token.IsEmpty()) {
token.CompressWhitespace();
if (millis == -1 && nsCRT::IsAsciiDigit(token.First())) {
PRInt32 i = 0;
PRUnichar value = nsnull;
while ((value = token[i++])) {
if (!nsCRT::IsAsciiDigit(value)) {
i = -1;
break;
}
}
PRBool tokenIsANumber = PR_TRUE;
nsReadingIterator<PRUnichar> doneIterating(token.EndReading());
nsReadingIterator<PRUnichar> iter(token.BeginReading());
while ( iter != doneIterating )
{
if ( !(tokenIsANumber = nsCRT::IsAsciiDigit(*iter)) )
break;
++iter;
}
if (i > -1) {
if (tokenIsANumber) {
PRInt32 err;
millis = token.ToInteger(&err) * 1000;
} else {