From: Lucian Grijincu Date: Mon, 9 May 2016 19:16:40 +0000 (-0700) Subject: folly: fbvector: ubsan: avoid memcpy(dest, nullptr, 0) X-Git-Tag: 2016.07.26~263 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d45588bd939f6303acea8061e86eedf4a901baa3;p=folly.git folly: fbvector: ubsan: avoid memcpy(dest, nullptr, 0) Reviewed By: meyering Differential Revision: D3277138 fbshipit-source-id: 7050d18c256ac15c8122d4af59aa31208b1466fd --- diff --git a/folly/FBVector.h b/folly/FBVector.h index e1809f31..fb611e56 100644 --- a/folly/FBVector.h +++ b/folly/FBVector.h @@ -636,7 +636,9 @@ private: } void relocate_move_or_memcpy(T* dest, T* first, T* last, std::true_type) { - std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T)); + if (first != nullptr) { + std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T)); + } } void relocate_move_or_memcpy(T* dest, T* first, T* last, std::false_type) {