1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Fix a UBsan bot.

If we do not initialize Prefix here, Prefix.data() returns a nullptr.
Later, it is passed to memcpy. memcpy's behavior is undefined if src (or
dst) is a nullptr even if a given size is 0. That's why this code
triggered UBsan.

llvm-svn: 314368
This commit is contained in:
Rui Ueyama 2017-09-28 00:27:39 +00:00
parent 9721e58798
commit 229877e82c

View File

@ -127,6 +127,7 @@ static void writePaxHeader(raw_fd_ostream &OS, StringRef Path) {
// Otherwise, returns false.
static bool splitUstar(StringRef Path, StringRef &Prefix, StringRef &Name) {
if (Path.size() < sizeof(UstarHeader::Name)) {
Prefix = "";
Name = Path;
return true;
}