Bug 1596544 - intl_ValidateAndCanonicalizeUnicodeExtensionType should ignore the second |option| argument until it's needed to report an error. r=anba default tip
authorJeff Walden <jwalden@mit.edu>
Tue, 19 Nov 2019 04:55:39 +0000
changeset 502538 b5c5ba07d3dbd0d07b66fa42a103f4df2c27d3a2
parent 502537 8ac99aff562c3065c7ad806e4ee54f1f85134668
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1596544
milestone72.0a1
Bug 1596544 - intl_ValidateAndCanonicalizeUnicodeExtensionType should ignore the second |option| argument until it's needed to report an error. r=anba Differential Revision: https://phabricator.services.mozilla.com/D53145
js/src/builtin/intl/Locale.cpp
--- a/js/src/builtin/intl/Locale.cpp
+++ b/js/src/builtin/intl/Locale.cpp
@@ -1338,29 +1338,26 @@ bool js::intl_TryValidateAndCanonicalize
   return true;
 }
 
 bool js::intl_ValidateAndCanonicalizeUnicodeExtensionType(JSContext* cx,
                                                           unsigned argc,
                                                           Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   MOZ_ASSERT(args.length() == 2);
+  MOZ_ASSERT(args[0].isString());
+  MOZ_ASSERT(args[1].isString());
 
   RootedLinearString unicodeType(cx, args[0].toString()->ensureLinear(cx));
   if (!unicodeType) {
     return false;
   }
 
-  RootedLinearString option(cx, args[1].toString()->ensureLinear(cx));
-  if (!option) {
-    return false;
-  }
-
   if (!IsValidUnicodeExtensionValue(unicodeType)) {
-    UniqueChars optionChars = EncodeAscii(cx, option);
+    UniqueChars optionChars = EncodeAscii(cx, args[1].toString());
     if (!optionChars) {
       return false;
     }
 
     UniqueChars unicodeTypeChars = QuoteString(cx, unicodeType, '"');
     if (!unicodeTypeChars) {
       return false;
     }