Ignore:
Timestamp:
Dec 1, 2017, 9:44:04 PM (7 years ago)
Author:
[email protected]
Message:

JavaScriptCore: missing exception checks in Math functions that take more than one argument
https://bugs.webkit.org/show_bug.cgi?id=180297
<rdar://problem/35745556>

Reviewed by Mark Lam.

JSTests:

  • stress/math-exceptions.js: Added.

(get try):
(catch):

Source/JavaScriptCore:

  • runtime/MathObject.cpp:

(JSC::mathProtoFuncATan2):
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):
(JSC::mathProtoFuncPow):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/MathObject.cpp

    r222473 r225443  
    150150EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec)
    151151{
     152    VM& vm = exec->vm();
     153    auto scope = DECLARE_THROW_SCOPE(vm);
    152154    double arg0 = exec->argument(0).toNumber(exec);
     155    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    153156    double arg1 = exec->argument(1).toNumber(exec);
     157    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    154158    return JSValue::encode(jsDoubleNumber(atan2(arg0, arg1)));
    155159}
     
    221225EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
    222226{
     227    VM& vm = exec->vm();
     228    auto scope = DECLARE_THROW_SCOPE(vm);
    223229    unsigned argsCount = exec->argumentCount();
    224230    double result = -std::numeric_limits<double>::infinity();
    225231    for (unsigned k = 0; k < argsCount; ++k) {
    226232        double val = exec->uncheckedArgument(k).toNumber(exec);
     233        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    227234        if (std::isnan(val)) {
    228235            result = PNaN;
     
    235242EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
    236243{
     244    VM& vm = exec->vm();
     245    auto scope = DECLARE_THROW_SCOPE(vm);
    237246    unsigned argsCount = exec->argumentCount();
    238247    double result = +std::numeric_limits<double>::infinity();
    239248    for (unsigned k = 0; k < argsCount; ++k) {
    240249        double val = exec->uncheckedArgument(k).toNumber(exec);
     250        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    241251        if (std::isnan(val)) {
    242252            result = PNaN;
     
    251261    // ECMA 15.8.2.1.13
    252262
     263    VM& vm = exec->vm();
     264    auto scope = DECLARE_THROW_SCOPE(vm);
     265
    253266    double arg = exec->argument(0).toNumber(exec);
     267    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    254268    double arg2 = exec->argument(1).toNumber(exec);
     269    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    255270
    256271    return JSValue::encode(JSValue(operationMathPow(arg, arg2)));
Note: See TracChangeset for help on using the changeset viewer.