Changeset 225851 in webkit


Ignore:
Timestamp:
Dec 13, 2017 10:20:53 AM (6 years ago)
Author:
Caio Lima
Message:

[ESNext][BigInt] Breking tests on Debug build and 32-bits due to missing Exception check
https://bugs.webkit.org/show_bug.cgi?id=180746

Reviewed by Saam Barati.

We have some uncatched exceptions that could happen due to OOM into
JSBigInt::allocateFor and JSBigInt::toStringGeneric. This patching is
catching such exceptions properly.

  • runtime/JSBigInt.cpp:

(JSC::JSBigInt::allocateFor):
(JSC::JSBigInt::parseInt):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::toStringSlowCase const):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r225845 r225851  
     12017-12-13  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ESNext][BigInt] Breking tests on Debug build and 32-bits due to missing Exception check
     4        https://bugs.webkit.org/show_bug.cgi?id=180746
     5
     6        Reviewed by Saam Barati.
     7
     8        We have some uncatched exceptions that could happen due to OOM into
     9        JSBigInt::allocateFor and JSBigInt::toStringGeneric. This patching is
     10        catching such exceptions properly.
     11
     12        * runtime/JSBigInt.cpp:
     13        (JSC::JSBigInt::allocateFor):
     14        (JSC::JSBigInt::parseInt):
     15        * runtime/JSCJSValue.cpp:
     16        (JSC::JSValue::toStringSlowCase const):
     17
    1182017-12-13  Saam Barati  <sbarati@apple.com>
    219
  • trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp

    r225799 r225851  
    4848#include "JSBigInt.h"
    4949
     50#include "CatchScope.h"
    5051#include "JSCInlines.h"
    5152#include "MathCommon.h"
     
    579580    ASSERT(charcount >= 0);
    580581
    581     auto scope = DECLARE_THROW_SCOPE(vm);
    582 
    583582    size_t bitsPerChar = maxBitsPerCharTable[radix];
    584583    size_t chars = charcount;
     
    599598    }
    600599
    601     if (state)
     600    if (state) {
     601        auto scope = DECLARE_THROW_SCOPE(vm);
    602602        throwOutOfMemoryError(state, scope);
     603    }
    603604    return nullptr;
    604605}
     
    656657    int limitA = 'A' + (radix - 10);
    657658
     659    auto scope = DECLARE_CATCH_SCOPE(vm);
    658660    JSBigInt* result = allocateFor(state, vm, radix, length - p);
    659     if (!result)
    660         return nullptr;
     661    RETURN_IF_EXCEPTION(scope, nullptr);
    661662
    662663    result->initialize(InitializationType::WithZero);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r225799 r225851  
    384384        if (auto digit = bigInt->singleDigitValueForString())
    385385            return vm.smallStrings.singleCharacterString(*digit + '0');
    386         return jsNontrivialString(&vm, bigInt->toString(*exec, 10));
     386        JSString* returnString = jsNontrivialString(&vm, bigInt->toString(*exec, 10));
     387        RETURN_IF_EXCEPTION(scope, errorValue());
     388        return returnString;
    387389    }
    388390
Note: See TracChangeset for help on using the changeset viewer.