Bug 1596547 - be more specific in CryptoBuffer::Assign parameter types; r=jcj
authorNathan Froyd <froydnj@mozilla.com>
Fri, 15 Nov 2019 13:12:58 +0000
changeset 502161 5ea9ed99c555bc7e07a8dfc9dfbbdb6eaa77c6e4
parent 502160 8a556d81b030513a068e8820f90e3940e675fbda
child 502162 53c096b278f5888d8b7590786628b0634a80ed2f
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/dom/crypto/CryptoBuffer.cpp
+++ b/dom/crypto/CryptoBuffer.cpp
@@ -69,16 +69,21 @@ uint8_t* CryptoBuffer::Assign(const Owni
   // If your union is uninitialized, something's wrong
   return nullptr;
+uint8_t* CryptoBuffer::Assign(const Uint8Array& aArray) {
+  aArray.ComputeLengthAndData();
+  return Assign(aArray.Data(), aArray.Length());
 uint8_t* CryptoBuffer::AppendSECItem(const SECItem* aItem) {
   return AppendElements(aItem->data, aItem->len, fallible);
 uint8_t* CryptoBuffer::AppendSECItem(const SECItem& aItem) {
   return AppendElements(aItem.data, aItem.len, fallible);
--- a/dom/crypto/CryptoBuffer.h
+++ b/dom/crypto/CryptoBuffer.h
@@ -23,30 +23,21 @@ class CryptoBuffer : public FallibleTArr
   uint8_t* Assign(const uint8_t* aData, uint32_t aLength);
   uint8_t* Assign(const nsACString& aString);
   uint8_t* Assign(const SECItem* aItem);
   uint8_t* Assign(const nsTArray<uint8_t>& aData);
   uint8_t* Assign(const ArrayBuffer& aData);
   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;
   JSObject* ToUint8Array(JSContext* aCx) const;
   JSObject* ToArrayBuffer(JSContext* aCx) const;
   bool ToNewUnsignedBuffer(uint8_t** aBuf, uint32_t* aBufLen) const;
   bool GetBigIntValue(unsigned long& aRetVal);