91744 - Avoid stack overflow by replacing recursion with a simple do-while. Removed unwanted assertions. r=heikki,sr=vidur
This commit is contained in:
@@ -1546,18 +1546,22 @@ nsresult ConsumeAttributeValueText(nsString& aString,
|
|||||||
const nsReadEndCondition& aEndCondition,
|
const nsReadEndCondition& aEndCondition,
|
||||||
PRInt32 aFlag)
|
PRInt32 aFlag)
|
||||||
{
|
{
|
||||||
nsresult result=aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
nsresult result = NS_OK;
|
||||||
|
PRBool done = PR_FALSE;
|
||||||
if(NS_SUCCEEDED(result)) {
|
|
||||||
PRUnichar ch;
|
do {
|
||||||
aScanner.Peek(ch);
|
result = aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||||
if(ch==kAmpersand) {
|
if(NS_SUCCEEDED(result)) {
|
||||||
result=ConsumeAttributeEntity(aString,aScanner,aFlag);
|
PRUnichar ch;
|
||||||
if (NS_SUCCEEDED(result)) {
|
aScanner.Peek(ch);
|
||||||
result=ConsumeAttributeValueText(aString,aScanner,aEndCondition,aFlag);
|
if(ch == kAmpersand) {
|
||||||
|
result = ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (NS_SUCCEEDED(result) && !done);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1934,7 +1938,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
result=aScanner.GetChar(aChar);
|
result=aScanner.GetChar(aChar);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
aString.Append(aChar);
|
aString.Append(aChar);
|
||||||
if(aChar==kRightBrace)
|
if(aChar==kRightBrace)
|
||||||
@@ -1947,7 +1954,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
if (kHashsign==aChar) {
|
if (kHashsign==aChar) {
|
||||||
result = aScanner.Peek(theChar,2);
|
result = aScanner.Peek(theChar,2);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (nsCRT::IsAsciiDigit(theChar)) {
|
if (nsCRT::IsAsciiDigit(theChar)) {
|
||||||
aScanner.GetChar(aChar); // Consume &
|
aScanner.GetChar(aChar); // Consume &
|
||||||
@@ -1969,7 +1979,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = aScanner.Peek(theChar,1);
|
result = aScanner.Peek(theChar,1);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if(nsCRT::IsAsciiAlpha(theChar) ||
|
if(nsCRT::IsAsciiAlpha(theChar) ||
|
||||||
theChar == '_' ||
|
theChar == '_' ||
|
||||||
@@ -1983,10 +1996,15 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result=aScanner.Peek(aChar);
|
result=aScanner.Peek(aChar);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (aChar == kSemicolon) {
|
if (aChar == kSemicolon) {
|
||||||
// consume semicolon that stopped the scan
|
// consume semicolon that stopped the scan
|
||||||
|
|||||||
@@ -1546,18 +1546,22 @@ nsresult ConsumeAttributeValueText(nsString& aString,
|
|||||||
const nsReadEndCondition& aEndCondition,
|
const nsReadEndCondition& aEndCondition,
|
||||||
PRInt32 aFlag)
|
PRInt32 aFlag)
|
||||||
{
|
{
|
||||||
nsresult result=aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
nsresult result = NS_OK;
|
||||||
|
PRBool done = PR_FALSE;
|
||||||
if(NS_SUCCEEDED(result)) {
|
|
||||||
PRUnichar ch;
|
do {
|
||||||
aScanner.Peek(ch);
|
result = aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||||
if(ch==kAmpersand) {
|
if(NS_SUCCEEDED(result)) {
|
||||||
result=ConsumeAttributeEntity(aString,aScanner,aFlag);
|
PRUnichar ch;
|
||||||
if (NS_SUCCEEDED(result)) {
|
aScanner.Peek(ch);
|
||||||
result=ConsumeAttributeValueText(aString,aScanner,aEndCondition,aFlag);
|
if(ch == kAmpersand) {
|
||||||
|
result = ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (NS_SUCCEEDED(result) && !done);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1934,7 +1938,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
result=aScanner.GetChar(aChar);
|
result=aScanner.GetChar(aChar);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
aString.Append(aChar);
|
aString.Append(aChar);
|
||||||
if(aChar==kRightBrace)
|
if(aChar==kRightBrace)
|
||||||
@@ -1947,7 +1954,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
if (kHashsign==aChar) {
|
if (kHashsign==aChar) {
|
||||||
result = aScanner.Peek(theChar,2);
|
result = aScanner.Peek(theChar,2);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (nsCRT::IsAsciiDigit(theChar)) {
|
if (nsCRT::IsAsciiDigit(theChar)) {
|
||||||
aScanner.GetChar(aChar); // Consume &
|
aScanner.GetChar(aChar); // Consume &
|
||||||
@@ -1969,7 +1979,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = aScanner.Peek(theChar,1);
|
result = aScanner.Peek(theChar,1);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if(nsCRT::IsAsciiAlpha(theChar) ||
|
if(nsCRT::IsAsciiAlpha(theChar) ||
|
||||||
theChar == '_' ||
|
theChar == '_' ||
|
||||||
@@ -1983,10 +1996,15 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result=aScanner.Peek(aChar);
|
result=aScanner.Peek(aChar);
|
||||||
NS_ENSURE_SUCCESS(result,result);
|
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (aChar == kSemicolon) {
|
if (aChar == kSemicolon) {
|
||||||
// consume semicolon that stopped the scan
|
// consume semicolon that stopped the scan
|
||||||
|
|||||||
Reference in New Issue
Block a user