Encoded object stream should be sequential
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 01:12:29 +0000 (01:12 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Nov 2013 01:12:29 +0000 (01:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123939

Reviewed by Andreas Kling.

Reserve space in the object stream for objects that are to be encoded, otherwise
the object stream will not be sequential.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeToObjectStream):
* Shared/ImmutableArray.h:
(WebKit::ImmutableArray::entries):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158805 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm
Source/WebKit2/Shared/ImmutableArray.h

index 8c7a68b..1f75fbb 100644 (file)
@@ -1,5 +1,20 @@
 2013-11-06  Anders Carlsson  <andersca@apple.com>
 
+        Encoded object stream should be sequential
+        https://bugs.webkit.org/show_bug.cgi?id=123939
+
+        Reviewed by Andreas Kling.
+
+        Reserve space in the object stream for objects that are to be encoded, otherwise
+        the object stream will not be sequential.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (encodeToObjectStream):
+        * Shared/ImmutableArray.h:
+        (WebKit::ImmutableArray::entries):
+
+2013-11-06  Anders Carlsson  <andersca@apple.com>
+
         Allow property list classes to exist in containers
         https://bugs.webkit.org/show_bug.cgi?id=123938
 
index dc749e6..51bebac 100644 (file)
@@ -104,7 +104,12 @@ static void encodeToObjectStream(WKRemoteObjectEncoder *encoder, id value)
 {
     ensureObjectStream(encoder);
 
-    encoder->_objectStream->append(createEncodedObject(encoder, value));
+    size_t position = encoder->_objectStream->size();
+    encoder->_objectStream->append(nullptr);
+
+    RefPtr<ImmutableDictionary> encodedObject = createEncodedObject(encoder, value);
+    ASSERT(!encoder->_objectStream->entries()[position]);
+    encoder->_objectStream->entries()[position] = encodedObject.release();
 }
 
 static void encodeInvocation(WKRemoteObjectEncoder *encoder, NSInvocation *invocation)
index 5b113ce..f37fa4b 100644 (file)
@@ -72,6 +72,7 @@ public:
     virtual bool isMutable() { return false; }
 
     const Vector<RefPtr<APIObject>>& entries() const { return m_entries; }
+    Vector<RefPtr<APIObject>>& entries() { return m_entries; }
 
 protected:
     ImmutableArray();