From 85ba05cab00871e8577eaf43f2fca0dfb0fd1991 Mon Sep 17 00:00:00 2001 From: "scc%mozilla.org" Date: Thu, 15 Jun 2000 00:39:21 +0000 Subject: [PATCH] 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 --- .../html/document/src/nsHTMLContentSink.cpp | 19 ++++++++++--------- .../html/document/src/nsHTMLContentSink.cpp | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 933ec87f213..5afdde578c3 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -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 doneIterating(token.EndReading()); + nsReadingIterator 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 { diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 933ec87f213..5afdde578c3 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -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 doneIterating(token.EndReading()); + nsReadingIterator 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 {