diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-02 11:07:35 -0700 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-06-07 08:52:09 +0200 |
commit | 7bae162ed278ccd852dec80199c4c635f06d2945 (patch) | |
tree | 04820ea1ba44b247afe55a0f3454b347675916bb /ipc | |
parent | 1e70501a2cb56e96fe4094c1670f5e176c0bbb7b (diff) | |
download | aura-central-7bae162ed278ccd852dec80199c4c635f06d2945.tar.gz |
Refactor structured clone JSAPI to prevent mismatched scopes.
Roll-up of bugs 1442722, 1455071, 1433642, 1456604 and 1458320.
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/glue/IPCMessageUtils.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 15834a854..c6f8eda6d 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -63,15 +63,18 @@ struct null_t { struct SerializedStructuredCloneBuffer final { + SerializedStructuredCloneBuffer() + : data(JS::StructuredCloneScope::Unassigned) + { + } + + SerializedStructuredCloneBuffer& operator=(const SerializedStructuredCloneBuffer& aOther) { data.Clear(); - auto iter = aOther.data.Iter(); - while (!iter.Done()) { - data.WriteBytes(iter.Data(), iter.RemainingInSegment()); - iter.Advance(aOther.data, iter.RemainingInSegment()); - } + data.initScope(aOther.data.scope()); + data.Append(aOther.data); return *this; } @@ -712,11 +715,9 @@ struct ParamTraits<JSStructuredCloneData> { MOZ_ASSERT(!(aParam.Size() % sizeof(uint64_t))); WriteParam(aMsg, aParam.Size()); - auto iter = aParam.Iter(); - while (!iter.Done()) { - aMsg->WriteBytes(iter.Data(), iter.RemainingInSegment(), sizeof(uint64_t)); - iter.Advance(aParam, iter.RemainingInSegment()); - } + aParam.ForEachDataChunk([&](const char* aData, size_t aSize) { + return aMsg->WriteBytes(aData, aSize, sizeof(uint64_t)); + }); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) @@ -746,7 +747,7 @@ struct ParamTraits<JSStructuredCloneData> return false; } - *aResult = JSStructuredCloneData(Move(out)); + *aResult = JSStructuredCloneData(Move(out), JS::StructuredCloneScope::DifferentProcess); return true; } |