summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-05-02 11:07:35 -0700
committerwolfbeast <mcwerewolf@gmail.com>2018-06-07 08:52:09 +0200
commit0e550f2fb90ada0b608bc1e1982b100291651806 (patch)
tree04820ea1ba44b247afe55a0f3454b347675916bb /ipc
parent835749ed6d411f006fe9d90ba7479233dcfe8ec7 (diff)
downloadUXP-0e550f2fb90ada0b608bc1e1982b100291651806.tar
UXP-0e550f2fb90ada0b608bc1e1982b100291651806.tar.gz
UXP-0e550f2fb90ada0b608bc1e1982b100291651806.tar.lz
UXP-0e550f2fb90ada0b608bc1e1982b100291651806.tar.xz
UXP-0e550f2fb90ada0b608bc1e1982b100291651806.zip
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.h23
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;
}