REGRESSION: [iOS 13?] TestWebKitAPI.SharedBufferTest.tryCreateArrayBufferLargeSegments is failing
https://bugs.webkit.org/show_bug.cgi?id=201902

Reviewed by Ryosuke Niwa.

Source/WebCore:

* Modules/webauthn/fido/U2fResponseConverter.cpp:
(fido::WebCore::createAttestedCredentialDataFromU2fRegisterResponse):

Source/WTF:

* wtf/Vector.h:
The code introduced in r108153 to workaround a warning when building Chrome was causing us to use uninitialized memory
when we create a Vector with the size_t/{signed,unsigned}char constructor with a constexpr size_t.
This was the cause of bug 201902 and bug 201620 which only manifested themselves in release builds with some compilers.

Tools:

* TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
(TestWebKitAPI::TEST_F):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 4879943..df39307 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-14  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION: [iOS 13?] TestWebKitAPI.SharedBufferTest.tryCreateArrayBufferLargeSegments is failing
+        https://bugs.webkit.org/show_bug.cgi?id=201902
+
+        Reviewed by Ryosuke Niwa.
+
+        * wtf/Vector.h:
+        The code introduced in r108153 to workaround a warning when building Chrome was causing us to use uninitialized memory
+        when we create a Vector with the size_t/{signed,unsigned}char constructor with a constexpr size_t.
+        This was the cause of bug 201902 and bug 201620 which only manifested themselves in release builds with some compilers.
+
 2019-10-14  Per Arne Vollan  <pvollan@apple.com>
 
         [macOS] Sandbox extensions should be created with audit tokens, not PIDs
diff --git a/Source/WTF/wtf/Vector.h b/Source/WTF/wtf/Vector.h
index 74e5aba..a4ed6ee 100644
--- a/Source/WTF/wtf/Vector.h
+++ b/Source/WTF/wtf/Vector.h
@@ -204,10 +204,7 @@
     static void uninitializedFill(T* dst, T* dstEnd, const T& val) 
     {
         static_assert(sizeof(T) == 1, "Size of type T should be equal to one!");
-#if COMPILER(GCC_COMPATIBLE) && defined(_FORTIFY_SOURCE)
-        if (!__builtin_constant_p(dstEnd - dst) || (!(dstEnd - dst)))
-#endif
-            memset(dst, val, dstEnd - dst);
+        memset(dst, val, dstEnd - dst);
     }
 };
 
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index c1f3eb1..92df240 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-14  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION: [iOS 13?] TestWebKitAPI.SharedBufferTest.tryCreateArrayBufferLargeSegments is failing
+        https://bugs.webkit.org/show_bug.cgi?id=201902
+
+        Reviewed by Ryosuke Niwa.
+
+        * Modules/webauthn/fido/U2fResponseConverter.cpp:
+        (fido::WebCore::createAttestedCredentialDataFromU2fRegisterResponse):
+
 2019-10-14  Russell Epstein  <russell_e@apple.com>
 
         Unreviewed, rolling out r251081.
diff --git a/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp b/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp
index ca6e38a..9324f18 100644
--- a/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp
+++ b/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp
@@ -98,9 +98,7 @@
     if (credentialId.isEmpty())
         return { };
 
-    Vector<uint8_t> aaguid(aaguidLength);
-    memset(aaguid.data(), 0, aaguidLength);
-    return buildAttestedCredentialData(aaguid, credentialId, publicKey);
+    return buildAttestedCredentialData(Vector<uint8_t>(aaguidLength, 0), credentialId, publicKey);
 }
 
 static size_t parseX509Length(const Vector<uint8_t>& u2fData, size_t offset)
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 03d5cb4..77e437f 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-14  Alex Christensen  <achristensen@webkit.org>
+
+        REGRESSION: [iOS 13?] TestWebKitAPI.SharedBufferTest.tryCreateArrayBufferLargeSegments is failing
+        https://bugs.webkit.org/show_bug.cgi?id=201902
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2019-10-14  Saam Barati  <sbarati@apple.com>
 
         Canonicalize how we prepare the prototype chain for inline caching
diff --git a/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp b/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp
index 1982731..eb92d50 100644
--- a/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp
@@ -101,7 +101,6 @@
     EXPECT_EQ(0, memcmp(expectedConcatenation, arrayBuffer->data(), strlen(expectedConcatenation)));
 }
 
-#if !PLATFORM(IOS) // FIXME: webkit.org/b/201902 REGRESSION: [iOS 13?] TestWebKitAPI.SharedBufferTest.tryCreateArrayBufferLargeSegments is failing
 TEST_F(SharedBufferTest, tryCreateArrayBufferLargeSegments)
 {
     Vector<char> vector0(0x4000, 'a');
@@ -127,7 +126,6 @@
         ++position;
     }
 }
-#endif // !PLATFORM(IOS)
 
 TEST_F(SharedBufferTest, copy)
 {