mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1277377 - prevent unsafe C-style cast in Vector (r=waldo)
MozReview-Commit-ID: L0bTDSBHOeY
This commit is contained in:
parent
38784200aa
commit
e574e0eda0
@ -163,7 +163,12 @@ struct VectorImpl<T, N, AP, true>
|
||||
MOZ_NONNULL(1)
|
||||
static inline void new_(T* aDst, Args&&... aArgs)
|
||||
{
|
||||
*aDst = T(Forward<Args>(aArgs)...);
|
||||
// Explicitly construct a local object instead of using a temporary since
|
||||
// T(args...) will be treated like a C-style cast in the unary case and
|
||||
// allow unsafe conversions. Both forms should be equivalent to an
|
||||
// optimizing compiler.
|
||||
T temp(Forward<Args>(aArgs)...);
|
||||
*aDst = temp;
|
||||
}
|
||||
|
||||
static inline void destroy(T*, T*) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user