From: Lucian Grijincu Date: Thu, 19 May 2016 08:14:49 +0000 (-0700) Subject: folly: FBString: avoid ubsan in assert X-Git-Tag: 2016.07.26~216 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4d78cf49cefb03bd8b376fa2061e5cbe7ee41746;p=folly.git folly: FBString: avoid ubsan in assert Summary: ``` buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7: runtime error: null pointer passed as argument 2, which is declared to never be null third-party-buck/build/glibc/include/string.h:70:33: note: nonnull attribute specified here #0 0x433a39 in _ZZN5folly13fbstring_coreIcEC1EPKcmbENKUlvE_clEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:365:7 #1 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_E7executeEv ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:153:29 #2 0x4335a9 in _ZN5folly14ScopeGuardImplIZNS_13fbstring_coreIcEC1EPKcmbEUlvE_ED2Ev ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/ScopeGuard.h:130 #3 0x4335a9 in folly::fbstring_core::fbstring_core(char const*, unsigned long, bool) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:427 #4 0x4353fa in folly::basic_fbstring, std::allocator, folly::fbstring_core >::basic_fbstring(char const*, unsigned long, std::allocator const&) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////buck-out/gen/folly/__default_headers__#default,headers/folly/FBString.h:1038:9 ``` Reviewed By: Gownta Differential Revision: D3321266 fbshipit-source-id: 28d5aef16e91a98066a1de6bab95403fbc63eaab --- diff --git a/folly/FBString.h b/folly/FBString.h index 4f0d3231..346d23c4 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -362,7 +362,7 @@ public: #ifndef _LIBSTDCXX_FBSTRING SCOPE_EXIT { assert(this->size() == size); - assert(memcmp(this->data(), data, size * sizeof(Char)) == 0); + assert(size == 0 || memcmp(this->data(), data, size * sizeof(Char)) == 0); }; #endif #endif