this is the last of them in my build of LLVM. Haven't tried Clang yet.
Found via UBSan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243934
91177308-0d34-0410-b5e6-
96231b3b80d8
/// CopyStringRef - Copies contents of a StringRef into a block of memory and
/// null-terminates it.
static void CopyStringRef(char *Memory, StringRef Data) {
- memcpy(Memory, Data.data(), Data.size());
+ if (!Data.empty())
+ memcpy(Memory, Data.data(), Data.size());
Memory[Data.size()] = 0; // Null terminate string.
}