From c03fd9b73f75e78d631c9ce14d9ea3fd4d4909af Mon Sep 17 00:00:00 2001 From: Lucian Grijincu Date: Mon, 9 May 2016 17:50:08 -0700 Subject: [PATCH] folly: ubsan: fix "reference binding to null pointer of type 'char'" Summary: third-party-buck/build/libgcc/include/c++/4.9.x/bits/stl_vector.h:866:9: runtime error: reference binding to null pointer of type 'char' ``` Breakpoint 2, 0x0000000000494894 in __ubsan_handle_type_mismatch_abort () (gdb) bt ``` Reviewed By: meyering, yfeldblum Differential Revision: D3279234 fbshipit-source-id: 63a761587e5b3f79ece09fc99b9a593da0e44b75 --- folly/test/FBStringTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/folly/test/FBStringTest.cpp b/folly/test/FBStringTest.cpp index 34858238..3d39b773 100644 --- a/folly/test/FBStringTest.cpp +++ b/folly/test/FBStringTest.cpp @@ -574,10 +574,10 @@ template void clause11_21_4_6_6(String & test) { template void clause11_21_4_6_7(String & test) { std::vector vec(random(0, maxString)); - test.copy( - &vec[0], - vec.size(), - random(0, test.size())); + if (vec.empty()) { + return; + } + test.copy(vec.data(), vec.size(), random(0, test.size())); } template void clause11_21_4_6_8(String & test) { -- 2.34.1