[UB] Fix another place where we would pass a null pointer to memcpy.

This too was found by UBSan. Down to 35 failures for me.

llvm-svn: 243932
This commit is contained in:
Chandler Carruth 2015-08-04 00:53:01 +00:00
parent 0cbe2efcd6
commit 13c247b455
1 changed files with 2 additions and 1 deletions

View File

@ -158,7 +158,8 @@ public:
// Copy the string information.
char *StrBuffer = const_cast<char*>(NewItem->getKeyData());
memcpy(StrBuffer, Key.data(), KeyLength);
if (KeyLength > 0)
memcpy(StrBuffer, Key.data(), KeyLength);
StrBuffer[KeyLength] = 0; // Null terminate for convenience of clients.
return NewItem;
}