Bug 960591 - Prevent implicitly constructing nsTArray<E> elements from E* pointers - r=ehsan

This commit is contained in:
Benoit Jacob 2014-01-17 11:54:19 -05:00
parent ed58dd2e28
commit 00e9c80dbb

View File

@ -524,6 +524,11 @@ public:
// Invoke the copy-constructor in place.
template<class A>
static inline void Construct(E *e, const A &arg) {
typedef typename mozilla::RemoveCV<E>::Type E_NoCV;
typedef typename mozilla::RemoveCV<A>::Type A_NoCV;
static_assert(!mozilla::IsSame<E_NoCV*, A_NoCV>::value,
"For safety, we disallow constructing nsTArray<E> elements "
"from E* pointers. See bug 960591.");
new (static_cast<void *>(e)) E(arg);
}
// Invoke the destructor in place.