Title: [261315] trunk/Source/_javascript_Core
Revision
261315
Author
da...@apple.com
Date
2020-05-07 11:02:11 -0700 (Thu, 07 May 2020)

Log Message

REGRESSION (r261257): Lifetime problem with upconverted characters in toLocaleCase
https://bugs.webkit.org/show_bug.cgi?id=211580
rdar://62980449

Reviewed by Yusuke Suzuki.

The problem comes from the fact that callBufferProducingFunction is moving the same
arguments multiple times. At the moment, this works around the only practical
problem with that, but later it should be fixed in callBufferProducingFunction.

* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Work around mistakes in how
callBufferProducingFunction works with arguments by calling get() explicitly on the
result of upconvertedCharacters. Later we could fix callBufferProducingFunction to
be safer, but for now this solves the problem.
* runtime/StringPrototype.cpp:
(JSC::toLocaleCase): Ditto.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (261314 => 261315)


--- trunk/Source/_javascript_Core/ChangeLog	2020-05-07 18:01:01 UTC (rev 261314)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-05-07 18:02:11 UTC (rev 261315)
@@ -1,3 +1,23 @@
+2020-05-07  Darin Adler  <da...@apple.com>
+
+        REGRESSION (r261257): Lifetime problem with upconverted characters in toLocaleCase
+        https://bugs.webkit.org/show_bug.cgi?id=211580
+        rdar://62980449
+
+        Reviewed by Yusuke Suzuki.
+
+        The problem comes from the fact that callBufferProducingFunction is moving the same
+        arguments multiple times. At the moment, this works around the only practical
+        problem with that, but later it should be fixed in callBufferProducingFunction.
+
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormat::initializeDateTimeFormat): Work around mistakes in how
+        callBufferProducingFunction works with arguments by calling get() explicitly on the
+        result of upconvertedCharacters. Later we could fix callBufferProducingFunction to
+        be safer, but for now this solves the problem.
+        * runtime/StringPrototype.cpp:
+        (JSC::toLocaleCase): Ditto.
+
 2020-05-07  Keith Miller  <keith_mil...@apple.com>
 
         Fix ArrayMode nodes after r261260

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (261314 => 261315)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2020-05-07 18:01:01 UTC (rev 261314)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2020-05-07 18:02:11 UTC (rev 261315)
@@ -619,7 +619,7 @@
     String skeleton = skeletonBuilder.toString();
     StringView skeletonView(skeleton);
     Vector<UChar, 32> patternBuffer;
-    status = callBufferProducingFunction(udatpg_getBestPatternWithOptions, generator, skeletonView.upconvertedCharacters(), skeletonView.length(), UDATPG_MATCH_HOUR_FIELD_LENGTH, patternBuffer);
+    status = callBufferProducingFunction(udatpg_getBestPatternWithOptions, generator, skeletonView.upconvertedCharacters().get(), skeletonView.length(), UDATPG_MATCH_HOUR_FIELD_LENGTH, patternBuffer);
     udatpg_close(generator);
     if (U_FAILURE(status)) {
         throwTypeError(globalObject, scope, "failed to initialize DateTimeFormat"_s);

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (261314 => 261315)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-05-07 18:01:01 UTC (rev 261314)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-05-07 18:02:11 UTC (rev 261315)
@@ -1614,7 +1614,7 @@
     Vector<UChar> buffer;
     buffer.reserveInitialCapacity(s.length());
     auto convertCase = mode == CaseConversionMode::Lower ? u_strToLower : u_strToUpper;
-    auto status = callBufferProducingFunction(convertCase, buffer, StringView { s }.upconvertedCharacters(), s.length(), locale.utf8().data());
+    auto status = callBufferProducingFunction(convertCase, buffer, StringView { s }.upconvertedCharacters().get(), s.length(), locale.utf8().data());
     if (U_FAILURE(status))
         return throwVMTypeError(globalObject, scope, u_errorName(status));
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to