diff options
author | Rui Ueyama <ruiu@google.com> | 2017-09-28 00:27:39 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-09-28 00:27:39 +0000 |
commit | 5908845a7e7c6db39e100246a3875f519f5d1f97 (patch) | |
tree | e3fd1d0264b0fc423963d896b243bdb244c5cd86 | |
parent | 64094f86212d6b81434cb7c26e965ff53f1e3fa0 (diff) | |
download | bcm5719-llvm-5908845a7e7c6db39e100246a3875f519f5d1f97.tar.gz bcm5719-llvm-5908845a7e7c6db39e100246a3875f519f5d1f97.zip |
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
-rw-r--r-- | llvm/lib/Support/TarWriter.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Support/TarWriter.cpp b/llvm/lib/Support/TarWriter.cpp index 5ae64741c52..5009607a478 100644 --- a/llvm/lib/Support/TarWriter.cpp +++ b/llvm/lib/Support/TarWriter.cpp @@ -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; } |