From: Lucian Grijincu Date: Tue, 10 May 2016 00:50:08 +0000 (-0700) Subject: folly: ubsan: fix "reference binding to null pointer of type 'char'" X-Git-Tag: 2016.07.26~257 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c03fd9b73f75e78d631c9ce14d9ea3fd4d4909af;p=folly.git 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 --- 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) {