mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 17:22:04 +00:00
91744 - Avoid stack overflow by replacing recursion with a simple do-while. Removed unwanted assertions. r=heikki,sr=vidur
This commit is contained in:
parent
1f8f8d5c07
commit
1936f6c0d2
@ -1546,18 +1546,22 @@ nsresult ConsumeAttributeValueText(nsString& aString,
|
||||
const nsReadEndCondition& aEndCondition,
|
||||
PRInt32 aFlag)
|
||||
{
|
||||
nsresult result=aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
PRUnichar ch;
|
||||
aScanner.Peek(ch);
|
||||
if(ch==kAmpersand) {
|
||||
result=ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result=ConsumeAttributeValueText(aString,aScanner,aEndCondition,aFlag);
|
||||
nsresult result = NS_OK;
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
do {
|
||||
result = aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
PRUnichar ch;
|
||||
aScanner.Peek(ch);
|
||||
if(ch == kAmpersand) {
|
||||
result = ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||
}
|
||||
else {
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (NS_SUCCEEDED(result) && !done);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1934,7 +1938,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
|
||||
do {
|
||||
result=aScanner.GetChar(aChar);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
aString.Append(aChar);
|
||||
if(aChar==kRightBrace)
|
||||
@ -1947,7 +1954,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
PRUnichar theChar=0;
|
||||
if (kHashsign==aChar) {
|
||||
result = aScanner.Peek(theChar,2);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (nsCRT::IsAsciiDigit(theChar)) {
|
||||
aScanner.GetChar(aChar); // Consume &
|
||||
@ -1969,7 +1979,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
}
|
||||
else {
|
||||
result = aScanner.Peek(theChar,1);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if(nsCRT::IsAsciiAlpha(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);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (aChar == kSemicolon) {
|
||||
// consume semicolon that stopped the scan
|
||||
|
@ -1546,18 +1546,22 @@ nsresult ConsumeAttributeValueText(nsString& aString,
|
||||
const nsReadEndCondition& aEndCondition,
|
||||
PRInt32 aFlag)
|
||||
{
|
||||
nsresult result=aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
PRUnichar ch;
|
||||
aScanner.Peek(ch);
|
||||
if(ch==kAmpersand) {
|
||||
result=ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result=ConsumeAttributeValueText(aString,aScanner,aEndCondition,aFlag);
|
||||
nsresult result = NS_OK;
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
do {
|
||||
result = aScanner.ReadUntil(aString,aEndCondition,PR_FALSE);
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
PRUnichar ch;
|
||||
aScanner.Peek(ch);
|
||||
if(ch == kAmpersand) {
|
||||
result = ConsumeAttributeEntity(aString,aScanner,aFlag);
|
||||
}
|
||||
else {
|
||||
done = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (NS_SUCCEEDED(result) && !done);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1934,7 +1938,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
|
||||
do {
|
||||
result=aScanner.GetChar(aChar);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
aString.Append(aChar);
|
||||
if(aChar==kRightBrace)
|
||||
@ -1947,7 +1954,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
PRUnichar theChar=0;
|
||||
if (kHashsign==aChar) {
|
||||
result = aScanner.Peek(theChar,2);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (nsCRT::IsAsciiDigit(theChar)) {
|
||||
aScanner.GetChar(aChar); // Consume &
|
||||
@ -1969,7 +1979,10 @@ CEntityToken::ConsumeEntity(PRUnichar aChar,
|
||||
}
|
||||
else {
|
||||
result = aScanner.Peek(theChar,1);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if(nsCRT::IsAsciiAlpha(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);
|
||||
NS_ENSURE_SUCCESS(result,result);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (aChar == kSemicolon) {
|
||||
// consume semicolon that stopped the scan
|
||||
|
Loading…
Reference in New Issue
Block a user