Bug 1596547 - be more specific in CryptoBuffer::Assign parameter types; r=jcj

We don't need the full generality of templated typed arrays here, just
the ability to assign from `Uint8Array`.  Some versions of clang in
C++17 mode have problems with overload resolution when faced with
templated method parameters that resolve to base classes of the passed
arguments.  Using the more-specific type here avoids those bugs.

Differential Revision: https://phabricator.services.mozilla.com/D53069

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-11-15 13:12:58 +00:00
Родитель e65a2c3ebb
Коммит f37a5156c3
2 изменённых файлов: 6 добавлений и 10 удалений

Просмотреть файл

@ -74,6 +74,11 @@ uint8_t* CryptoBuffer::Assign(const OwningArrayBufferViewOrArrayBuffer& aData) {
return nullptr;
}
uint8_t* CryptoBuffer::Assign(const Uint8Array& aArray) {
aArray.ComputeLengthAndData();
return Assign(aArray.Data(), aArray.Length());
}
uint8_t* CryptoBuffer::AppendSECItem(const SECItem* aItem) {
MOZ_ASSERT(aItem);
return AppendElements(aItem->data, aItem->len, fallible);

Просмотреть файл

@ -28,20 +28,11 @@ class CryptoBuffer : public FallibleTArray<uint8_t> {
uint8_t* Assign(const ArrayBufferView& aData);
uint8_t* Assign(const ArrayBufferViewOrArrayBuffer& aData);
uint8_t* Assign(const OwningArrayBufferViewOrArrayBuffer& aData);
uint8_t* Assign(const Uint8Array& aArray);
uint8_t* AppendSECItem(const SECItem* aItem);
uint8_t* AppendSECItem(const SECItem& aItem);
template <typename T, JSObject* UnwrapArray(JSObject*),
void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*,
T**)>
uint8_t* Assign(
const TypedArray_base<T, UnwrapArray, GetLengthAndDataAndSharedness>&
aArray) {
aArray.ComputeLengthAndData();
return Assign(aArray.Data(), aArray.Length());
}
nsresult FromJwkBase64(const nsString& aBase64);
nsresult ToJwkBase64(nsString& aBase64) const;
bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const;