mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Fix for bug 528300. r=sicking, a=blocking1.9.2+.
This commit is contained in:
parent
7d0dd55d2d
commit
4ca74861f6
22
content/xslt/crashtests/528300.xml
Normal file
22
content/xslt/crashtests/528300.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xml" href="#bug"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST xsl:transform
|
||||
id ID #REQUIRED>
|
||||
]>
|
||||
<doc>
|
||||
<xsl:transform
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="2.0"
|
||||
id="bug">
|
||||
<xsl:variable name="v0">
|
||||
<xsl:for-each select="$v0" />
|
||||
</xsl:variable>
|
||||
<xsl:template name="t2" match="/">
|
||||
<xsl:copy-of select="number($v0)" />
|
||||
</xsl:template>
|
||||
</xsl:transform>
|
||||
|
||||
<e1 />
|
||||
|
||||
</doc>
|
19
content/xslt/crashtests/528488.xml
Normal file
19
content/xslt/crashtests/528488.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xml" href="#bug"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST xsl:transform
|
||||
id ID #REQUIRED>
|
||||
]>
|
||||
<doc>
|
||||
<xsl:transform
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exslstrings="http://exslt.org/strings"
|
||||
version="2.0"
|
||||
id="bug">
|
||||
<xsl:variable name="v0" select="$v0" />
|
||||
<xsl:template name="t2" match="/">
|
||||
<xsl:param name="p0" select="exslstrings:tokenize('1234','foobar')" />
|
||||
<xsl:copy-of select="round($v0)" />
|
||||
</xsl:template>
|
||||
</xsl:transform>
|
||||
</doc>
|
@ -6,3 +6,5 @@ load 406106-1.html
|
||||
load 483444.xml
|
||||
load 485217.xml
|
||||
load 485286.xml
|
||||
load 528300.xml
|
||||
load 528488.xml
|
||||
|
@ -387,7 +387,9 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
rv = mParams[0]->evaluateToString(aContext, src);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
double start = evaluateToNumber(mParams[1], aContext);
|
||||
double start;
|
||||
rv = evaluateToNumber(mParams[1], aContext, &start);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// check for NaN or +/-Inf
|
||||
if (Double::isNaN(start) ||
|
||||
@ -402,8 +404,10 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
|
||||
double end;
|
||||
if (mParams.Length() == 3) {
|
||||
end = start + evaluateToNumber(mParams[2],
|
||||
aContext);
|
||||
rv = evaluateToNumber(mParams[2], aContext, &end);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
end += start;
|
||||
if (Double::isNaN(end) || end < 0) {
|
||||
aContext->recycler()->getEmptyStringResult(aResult);
|
||||
|
||||
@ -531,7 +535,8 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
{
|
||||
double res;
|
||||
if (!mParams.IsEmpty()) {
|
||||
res = evaluateToNumber(mParams[0], aContext);
|
||||
rv = evaluateToNumber(mParams[0], aContext, &res);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
nsAutoString resultStr;
|
||||
@ -543,7 +548,10 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
}
|
||||
case ROUND:
|
||||
{
|
||||
double dbl = evaluateToNumber(mParams[0], aContext);
|
||||
double dbl;
|
||||
rv = evaluateToNumber(mParams[0], aContext, &dbl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!Double::isNaN(dbl) && !Double::isInfinite(dbl)) {
|
||||
if (Double::isNeg(dbl) && dbl >= -0.5) {
|
||||
dbl *= 0;
|
||||
@ -557,7 +565,10 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
}
|
||||
case FLOOR:
|
||||
{
|
||||
double dbl = evaluateToNumber(mParams[0], aContext);
|
||||
double dbl;
|
||||
rv = evaluateToNumber(mParams[0], aContext, &dbl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!Double::isNaN(dbl) &&
|
||||
!Double::isInfinite(dbl) &&
|
||||
!(dbl == 0 && Double::isNeg(dbl))) {
|
||||
@ -568,7 +579,10 @@ txCoreFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
||||
}
|
||||
case CEILING:
|
||||
{
|
||||
double dbl = evaluateToNumber(mParams[0], aContext);
|
||||
double dbl;
|
||||
rv = evaluateToNumber(mParams[0], aContext, &dbl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!Double::isNaN(dbl) && !Double::isInfinite(dbl)) {
|
||||
if (Double::isNeg(dbl) && dbl > -1) {
|
||||
dbl *= 0;
|
||||
|
@ -330,7 +330,8 @@ protected:
|
||||
/*
|
||||
* Evaluates the given Expression and converts its result to a number.
|
||||
*/
|
||||
static double evaluateToNumber(Expr* aExpr, txIEvalContext* aContext);
|
||||
static nsresult evaluateToNumber(Expr* aExpr, txIEvalContext* aContext,
|
||||
double* aResult);
|
||||
|
||||
/*
|
||||
* Evaluates the given Expression and converts its result to a NodeSet.
|
||||
|
@ -52,15 +52,19 @@
|
||||
/*
|
||||
* Evaluates the given Expression and converts its result to a number.
|
||||
*/
|
||||
double FunctionCall::evaluateToNumber(Expr* aExpr, txIEvalContext* aContext)
|
||||
// static
|
||||
nsresult
|
||||
FunctionCall::evaluateToNumber(Expr* aExpr, txIEvalContext* aContext,
|
||||
double* aResult)
|
||||
{
|
||||
NS_ASSERTION(aExpr, "missing expression");
|
||||
nsRefPtr<txAExprResult> exprResult;
|
||||
nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprResult));
|
||||
if (NS_FAILED(rv))
|
||||
return Double::NaN;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return exprResult->numberValue();
|
||||
*aResult = exprResult->numberValue();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -479,7 +479,11 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
||||
}
|
||||
case eNUMBER:
|
||||
{
|
||||
invokeParam.val.d = evaluateToNumber(expr, aContext);
|
||||
double dbl;
|
||||
rv = evaluateToNumber(mParams[0], aContext, &dbl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
invokeParam.val.d = dbl;
|
||||
break;
|
||||
}
|
||||
case eSTRING:
|
||||
|
@ -99,10 +99,13 @@ txExecutionState::txExecutionState(txStylesheet* aStylesheet,
|
||||
mKeyHash(aStylesheet->getKeyMap()),
|
||||
mDisableLoads(aDisableLoads)
|
||||
{
|
||||
MOZ_COUNT_CTOR(txExecutionState);
|
||||
}
|
||||
|
||||
txExecutionState::~txExecutionState()
|
||||
{
|
||||
MOZ_COUNT_DTOR(txExecutionState);
|
||||
|
||||
delete mResultHandler;
|
||||
delete mLocalVariables;
|
||||
delete mEvalContext;
|
||||
@ -271,9 +274,9 @@ txExecutionState::getVariable(PRInt32 aNamespace, nsIAtom* aLName,
|
||||
txVariableMap* oldVars = mLocalVariables;
|
||||
mLocalVariables = nsnull;
|
||||
rv = var->mExpr->evaluate(getEvalContext(), &aResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mLocalVariables = oldVars;
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
nsAutoPtr<txRtfHandler> rtfHandler(new txRtfHandler);
|
||||
|
@ -84,10 +84,11 @@ txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext,
|
||||
double value;
|
||||
txExpandedName formatName;
|
||||
|
||||
value = evaluateToNumber(mParams[0], aContext);
|
||||
nsresult rv = evaluateToNumber(mParams[0], aContext, &value);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString formatStr;
|
||||
nsresult rv = mParams[1]->evaluateToString(aContext, formatStr);
|
||||
rv = mParams[1]->evaluateToString(aContext, formatStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mParams.Length() == 3) {
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
class txVariableMap {
|
||||
public:
|
||||
txVariableMap();
|
||||
~txVariableMap();
|
||||
|
||||
nsresult bindVariable(const txExpandedName& aName, txAExprResult* aValue);
|
||||
@ -59,9 +60,17 @@ private:
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
txVariableMap::txVariableMap()
|
||||
{
|
||||
MOZ_COUNT_CTOR(txVariableMap);
|
||||
}
|
||||
|
||||
inline
|
||||
txVariableMap::~txVariableMap()
|
||||
{
|
||||
MOZ_COUNT_DTOR(txVariableMap);
|
||||
|
||||
txExpandedNameMap<txAExprResult>::iterator iter(mMap);
|
||||
while (iter.next()) {
|
||||
txAExprResult* res = iter.value();
|
||||
|
Loading…
Reference in New Issue
Block a user