Skip to content

Commit

Permalink
folly: fbvector: ubsan: don't call memcpy() with nullptr args if size…
Browse files Browse the repository at this point in the history
… == 0

Reviewed By: meyering, luciang

Differential Revision: D3310683

fbshipit-source-id: c86471d54062b2f3455f15fb73340fac486d9e44
  • Loading branch information
Marcus Holland-Moritz authored and Facebook Github Bot 2 committed May 17, 2016
1 parent 01dbb37 commit 1072a89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions folly/FBVector.h
Expand Up @@ -522,15 +522,19 @@ class fbvector : private boost::totally_ordered<fbvector<T, Allocator>> {

static void
S_uninitialized_copy_bits(T* dest, const T* first, const T* last) {
std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
if (last != first) {
std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
}
}

static void
S_uninitialized_copy_bits(T* dest, std::move_iterator<T*> first,
std::move_iterator<T*> last) {
T* bFirst = first.base();
T* bLast = last.base();
std::memcpy((void*)dest, (void*)bFirst, (bLast - bFirst) * sizeof(T));
if (bLast != bFirst) {
std::memcpy((void*)dest, (void*)bFirst, (bLast - bFirst) * sizeof(T));
}
}

template <typename It>
Expand Down

0 comments on commit 1072a89

Please sign in to comment.