diff options
author | Moonchild <moonchild@palemoon.org> | 2020-06-03 09:44:20 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-06-03 10:49:35 +0000 |
commit | 54b4fb0be65011d4ba706144a2a508a3a74796ac (patch) | |
tree | 785818dc5fa8401543775567e80740082cb60923 /dom/media | |
parent | a054ece0412bcd783b78e18f1aea48f6df4fe837 (diff) | |
download | UXP-54b4fb0be65011d4ba706144a2a508a3a74796ac.tar UXP-54b4fb0be65011d4ba706144a2a508a3a74796ac.tar.gz UXP-54b4fb0be65011d4ba706144a2a508a3a74796ac.tar.lz UXP-54b4fb0be65011d4ba706144a2a508a3a74796ac.tar.xz UXP-54b4fb0be65011d4ba706144a2a508a3a74796ac.zip |
Bug 1632717
Diffstat (limited to 'dom/media')
-rw-r--r-- | dom/media/eme/EMEUtils.cpp | 12 | ||||
-rw-r--r-- | dom/media/eme/EMEUtils.h | 4 | ||||
-rw-r--r-- | dom/media/eme/MediaEncryptedEvent.cpp | 8 | ||||
-rw-r--r-- | dom/media/eme/MediaKeyMessageEvent.cpp | 7 |
4 files changed, 24 insertions, 7 deletions
diff --git a/dom/media/eme/EMEUtils.cpp b/dom/media/eme/EMEUtils.cpp index 11eb0026e..93e7834e3 100644 --- a/dom/media/eme/EMEUtils.cpp +++ b/dom/media/eme/EMEUtils.cpp @@ -5,6 +5,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/EMEUtils.h" + +#include "jsfriendapi.h" // for AutoCheckCannotGC #include "mozilla/dom/UnionTypes.h" namespace mozilla { @@ -23,6 +25,7 @@ ArrayData GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView) { MOZ_ASSERT(aBufferOrView.IsArrayBuffer() || aBufferOrView.IsArrayBufferView()); + JS::AutoCheckCannotGC nogc; if (aBufferOrView.IsArrayBuffer()) { const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer(); buffer.ComputeLengthAndData(); @@ -39,6 +42,7 @@ void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView, nsTArray<uint8_t>& aOutData) { + JS::AutoCheckCannotGC nogc; ArrayData data = GetArrayBufferViewOrArrayBufferData(aBufferOrView); aOutData.Clear(); if (!data.IsValid()) { @@ -47,6 +51,14 @@ CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aB aOutData.AppendElements(data.mData, data.mLength); } +void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBuffer, + nsTArray<uint8_t>& aOutData) { + JS::AutoCheckCannotGC nogc; + aBuffer.ComputeLengthAndData(); + aOutData.Clear(); + aOutData.AppendElements(aBuffer.Data(), aBuffer.Length()); +} + bool IsClearkeyKeySystem(const nsAString& aKeySystem) { diff --git a/dom/media/eme/EMEUtils.h b/dom/media/eme/EMEUtils.h index 4a2e5da18..3b5d88561 100644 --- a/dom/media/eme/EMEUtils.h +++ b/dom/media/eme/EMEUtils.h @@ -45,6 +45,10 @@ void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView, nsTArray<uint8_t>& aOutData); +// Overload for ArrayBuffer +void CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBuffer& aBufferOrView, + nsTArray<uint8_t>& aOutData); + struct ArrayData { explicit ArrayData(const uint8_t* aData, size_t aLength) : mData(aData) diff --git a/dom/media/eme/MediaEncryptedEvent.cpp b/dom/media/eme/MediaEncryptedEvent.cpp index 8e2595fcb..fe1c8a3bc 100644 --- a/dom/media/eme/MediaEncryptedEvent.cpp +++ b/dom/media/eme/MediaEncryptedEvent.cpp @@ -87,10 +87,10 @@ MediaEncryptedEvent::Constructor(const GlobalObject& aGlobal, e->mInitDataType = aEventInitDict.mInitDataType; if (!aEventInitDict.mInitData.IsNull()) { const auto& a = aEventInitDict.mInitData.Value(); - a.ComputeLengthAndData(); - e->mInitData = ArrayBuffer::Create(aGlobal.Context(), - a.Length(), - a.Data()); + nsTArray<uint8_t> initData; + CopyArrayBufferViewOrArrayBufferData(a, initData); + e->mInitData = ArrayBuffer::Create(aGlobal.Context(), initData.Length(), + initData.Elements()); if (!e->mInitData) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return nullptr; diff --git a/dom/media/eme/MediaKeyMessageEvent.cpp b/dom/media/eme/MediaKeyMessageEvent.cpp index 37c509e67..289d0c16e 100644 --- a/dom/media/eme/MediaKeyMessageEvent.cpp +++ b/dom/media/eme/MediaKeyMessageEvent.cpp @@ -85,10 +85,11 @@ MediaKeyMessageEvent::Constructor(const GlobalObject& aGlobal, RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner); bool trusted = e->Init(owner); e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable); - aEventInitDict.mMessage.ComputeLengthAndData(); + nsTArray<uint8_t> initData; + CopyArrayBufferViewOrArrayBufferData(aEventInitDict.mMessage, initData); e->mMessage = ArrayBuffer::Create(aGlobal.Context(), - aEventInitDict.mMessage.Length(), - aEventInitDict.mMessage.Data()); + initData.Length(), + initData.Elements()); if (!e->mMessage) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return nullptr; |