Title: [247744] branches/safari-608-branch/Source/WebKit

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (247743 => 247744)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-23 20:59:08 UTC (rev 247743)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-23 20:59:13 UTC (rev 247744)
@@ -1,5 +1,9 @@
 2019-07-23  Alan Coon  <[email protected]>
 
+        Revert r247672. rdar://problem/53449739
+
+2019-07-23  Alan Coon  <[email protected]>
+
         Revert r247673. rdar://problem/53449723
 
 2019-07-23  Alan Coon  <[email protected]>

Modified: branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.cpp (247743 => 247744)


--- branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2019-07-23 20:59:08 UTC (rev 247743)
+++ branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2019-07-23 20:59:13 UTC (rev 247744)
@@ -132,22 +132,44 @@
 }
 
 template <typename CharacterType>
-static inline Optional<String> decodeStringText(Decoder& decoder, uint32_t length)
+static inline bool decodeStringText(Decoder& decoder, uint32_t length, String& result)
 {
     // Before allocating the string, make sure that the decoder buffer is big enough.
     if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length)) {
         decoder.markInvalid();
-        return WTF::nullopt;
+        return false;
     }
     
     CharacterType* buffer;
     String string = String::createUninitialized(length, buffer);
     if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(CharacterType), alignof(CharacterType)))
-        return WTF::nullopt;
+        return false;
     
-    return WTFMove(string);
+    result = string;
+    return true;    
 }
 
+bool ArgumentCoder<String>::decode(Decoder& decoder, String& result)
+{
+    uint32_t length;
+    if (!decoder.decode(length))
+        return false;
+
+    if (length == std::numeric_limits<uint32_t>::max()) {
+        // This is the null string.
+        result = String();
+        return true;
+    }
+
+    bool is8Bit;
+    if (!decoder.decode(is8Bit))
+        return false;
+
+    if (is8Bit)
+        return decodeStringText<LChar>(decoder, length, result);
+    return decodeStringText<UChar>(decoder, length, result);
+}
+
 Optional<String> ArgumentCoder<String>::decode(Decoder& decoder)
 {
     uint32_t length;
@@ -163,21 +185,17 @@
     if (!decoder.decode(is8Bit))
         return WTF::nullopt;
     
-    if (is8Bit)
-        return decodeStringText<LChar>(decoder, length);
-    return decodeStringText<UChar>(decoder, length);
+    String result;
+    if (is8Bit) {
+        if (!decodeStringText<LChar>(decoder, length, result))
+            return WTF::nullopt;
+        return result;
+    }
+    if (!decodeStringText<UChar>(decoder, length, result))
+        return WTF::nullopt;
+    return result;
 }
 
-bool ArgumentCoder<String>::decode(Decoder& decoder, String& result)
-{
-    Optional<String> string;
-    decoder >> string;
-    if (!string)
-        return false;
-    result = WTFMove(*string);
-    return true;
-}
-
 void ArgumentCoder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest)
 {
     encoder.encodeFixedLengthData(digest.data(), sizeof(digest), 1);

Modified: branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.h (247743 => 247744)


--- branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-07-23 20:59:08 UTC (rev 247743)
+++ branches/safari-608-branch/Source/WebKit/Platform/IPC/ArgumentCoders.h	2019-07-23 20:59:13 UTC (rev 247744)
@@ -366,30 +366,56 @@
 
     static void encode(Encoder& encoder, const HashMapType& hashMap)
     {
-        encoder << static_cast<uint32_t>(hashMap.size());
+        encoder << static_cast<uint64_t>(hashMap.size());
         for (typename HashMapType::const_iterator it = hashMap.begin(), end = hashMap.end(); it != end; ++it)
             encoder << *it;
     }
 
+    static bool decode(Decoder& decoder, HashMapType& hashMap)
+    {
+        uint64_t hashMapSize;
+        if (!decoder.decode(hashMapSize))
+            return false;
+
+        HashMapType tempHashMap;
+        for (uint64_t i = 0; i < hashMapSize; ++i) {
+            KeyArg key;
+            MappedArg value;
+            if (!decoder.decode(key))
+                return false;
+            if (!decoder.decode(value))
+                return false;
+
+            if (!tempHashMap.add(key, value).isNewEntry) {
+                // The hash map already has the specified key, bail.
+                decoder.markInvalid();
+                return false;
+            }
+        }
+
+        hashMap.swap(tempHashMap);
+        return true;
+    }
+
     static Optional<HashMapType> decode(Decoder& decoder)
     {
-        uint32_t hashMapSize;
+        uint64_t hashMapSize;
         if (!decoder.decode(hashMapSize))
             return WTF::nullopt;
 
         HashMapType hashMap;
-        for (uint32_t i = 0; i < hashMapSize; ++i) {
+        for (uint64_t i = 0; i < hashMapSize; ++i) {
             Optional<KeyArg> key;
             decoder >> key;
-            if (UNLIKELY(!key))
+            if (!key)
                 return WTF::nullopt;
 
             Optional<MappedArg> value;
             decoder >> value;
-            if (UNLIKELY(!value))
+            if (!value)
                 return WTF::nullopt;
 
-            if (UNLIKELY(!hashMap.add(WTFMove(*key), WTFMove(*value)).isNewEntry)) {
+            if (!hashMap.add(WTFMove(key.value()), WTFMove(value.value())).isNewEntry) {
                 // The hash map already has the specified key, bail.
                 decoder.markInvalid();
                 return WTF::nullopt;
@@ -396,18 +422,8 @@
             }
         }
 
-        return WTFMove(hashMap);
+        return hashMap;
     }
-
-    static bool decode(Decoder& decoder, HashMapType& hashMap)
-    {
-        Optional<HashMapType> tempHashMap;
-        decoder >> tempHashMap;
-        if (!tempHashMap)
-            return false;
-        hashMap.swap(*tempHashMap);
-        return true;
-    }
 };
 
 template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct ArgumentCoder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to