From d45588bd939f6303acea8061e86eedf4a901baa3 Mon Sep 17 00:00:00 2001 From: Lucian Grijincu Date: Mon, 9 May 2016 12:16:40 -0700 Subject: [PATCH] folly: fbvector: ubsan: avoid memcpy(dest, nullptr, 0) Reviewed By: meyering Differential Revision: D3277138 fbshipit-source-id: 7050d18c256ac15c8122d4af59aa31208b1466fd --- folly/FBVector.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { -- 2.34.1