Changeset 249164 in webkit


Ignore:
Timestamp:
Aug 27, 2019 1:10:40 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

constructFunctionSkippingEvalEnabledCheck() should use tryMakeString() and check for OOM.
https://bugs.webkit.org/show_bug.cgi?id=201196
<rdar://problem/54703775>

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/constructFunctionSkippingEvalEnabledCheck-should-throw-out-of-memory-error.js: Added.

Source/JavaScriptCore:

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r249117 r249164  
     12019-08-27  Mark Lam  <mark.lam@apple.com>
     2
     3        constructFunctionSkippingEvalEnabledCheck() should use tryMakeString() and check for OOM.
     4        https://bugs.webkit.org/show_bug.cgi?id=201196
     5        <rdar://problem/54703775>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * stress/constructFunctionSkippingEvalEnabledCheck-should-throw-out-of-memory-error.js: Added.
     10
    1112019-08-26  Ross Kirsling  <ross.kirsling@sony.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r249159 r249164  
     12019-08-27  Mark Lam  <mark.lam@apple.com>
     2
     3        constructFunctionSkippingEvalEnabledCheck() should use tryMakeString() and check for OOM.
     4        https://bugs.webkit.org/show_bug.cgi?id=201196
     5        <rdar://problem/54703775>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * runtime/FunctionConstructor.cpp:
     10        (JSC::constructFunctionSkippingEvalEnabledCheck):
     11
    1122019-08-27  Keith Miller  <keith_miller@apple.com>
    213
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r249013 r249164  
    110110        auto body = args.at(0).toWTFString(exec);
    111111        RETURN_IF_EXCEPTION(scope, nullptr);
    112         program = makeString(prefix, functionName.string(), "() {\n", body, "\n}");
     112        program = tryMakeString(prefix, functionName.string(), "() {\n", body, "\n}");
     113        if (UNLIKELY(!program)) {
     114            throwOutOfMemoryError(exec, scope);
     115            return nullptr;
     116        }
    113117    } else {
    114118        StringBuilder builder(StringBuilder::OverflowHandler::RecordOverflow);
     
    123127            builder.append(", ", viewWithString.view);
    124128        }
    125         if (builder.hasOverflowed()) {
     129        if (UNLIKELY(builder.hasOverflowed())) {
    126130            throwOutOfMemoryError(exec, scope);
    127131            return nullptr;
     
    133137        RETURN_IF_EXCEPTION(scope, nullptr);
    134138        builder.append(") {\n", body.view, "\n}");
    135         if (builder.hasOverflowed()) {
     139        if (UNLIKELY(builder.hasOverflowed())) {
    136140            throwOutOfMemoryError(exec, scope);
    137141            return nullptr;
Note: See TracChangeset for help on using the changeset viewer.