Changeset 259481 in webkit


Ignore:
Timestamp:
Apr 3, 2020 11:40:05 AM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] canonicalizeLocaleList should gracefully throw OOM error if input + error message is too large
https://bugs.webkit.org/show_bug.cgi?id=209971
<rdar://problem/61258621>

Reviewed by Mark Lam.

JSTests:

  • stress/intl-canonicalize-locale-list-error-oom.js: Added.

(shouldThrow):

Source/JavaScriptCore:

canonicalizeLocaleList generates error-message with input. If input is too large, error-message string
generation could fail due to OOM. We should gracefully throw OOM error instead of crashing. This strategy
follows to createError's error-message generation: if error-message generation fails, throwing OOM error.

  • runtime/IntlObject.cpp:

(JSC::canonicalizeLocaleList):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r259480 r259481  
     12020-04-03  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] canonicalizeLocaleList should gracefully throw OOM error if input + error message is too large
     4        https://bugs.webkit.org/show_bug.cgi?id=209971
     5        <rdar://problem/61258621>
     6
     7        Reviewed by Mark Lam.
     8
     9        * stress/intl-canonicalize-locale-list-error-oom.js: Added.
     10        (shouldThrow):
     11
    1122020-04-03  Ross Kirsling  <ross.kirsling@sony.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r259480 r259481  
     12020-04-03  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] canonicalizeLocaleList should gracefully throw OOM error if input + error message is too large
     4        https://bugs.webkit.org/show_bug.cgi?id=209971
     5        <rdar://problem/61258621>
     6
     7        Reviewed by Mark Lam.
     8
     9        canonicalizeLocaleList generates error-message with input. If input is too large, error-message string
     10        generation could fail due to OOM. We should gracefully throw OOM error instead of crashing. This strategy
     11        follows to `createError`'s error-message generation: if error-message generation fails, throwing OOM error.
     12
     13        * runtime/IntlObject.cpp:
     14        (JSC::canonicalizeLocaleList):
     15
    1162020-04-03  Ross Kirsling  <ross.kirsling@sony.com>
    217
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r255120 r259481  
    634634            if (!kValue.isString() && !kValue.isObject()) {
    635635                throwTypeError(globalObject, scope, "locale value must be a string or object"_s);
    636                 return Vector<String>();
     636                return { };
    637637            }
    638638
     
    645645            String canonicalizedTag = canonicalizeLanguageTag(tagValue);
    646646            if (canonicalizedTag.isNull()) {
    647                 throwException(globalObject, scope, createRangeError(globalObject, "invalid language tag: " + tagValue));
    648                 return Vector<String>();
     647                String errorMessage = tryMakeString("invalid language tag: ", tagValue);
     648                if (UNLIKELY(!errorMessage)) {
     649                    throwException(globalObject, scope, createOutOfMemoryError(globalObject));
     650                    return { };
     651                }
     652                throwException(globalObject, scope, createRangeError(globalObject, errorMessage));
     653                return { };
    649654            }
    650655
Note: See TracChangeset for help on using the changeset viewer.