summaryrefslogtreecommitdiff
path: root/lib/Support/Compression.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-04-23 12:17:46 +0000
committerAlexey Samsonov <samsonov@google.com>2013-04-23 12:17:46 +0000
commit39dd5aafb0a92536a8872ac4a9c39a56442c8023 (patch)
treeb03e425bd44f286795ca4c20c17b21e5dcd5e04b /lib/Support/Compression.cpp
parent2848ff01e2edd87a56fd85927e491e8d0a59ee3d (diff)
downloadllvm-39dd5aafb0a92536a8872ac4a9c39a56442c8023.tar.gz
llvm-39dd5aafb0a92536a8872ac4a9c39a56442c8023.tar.bz2
llvm-39dd5aafb0a92536a8872ac4a9c39a56442c8023.tar.xz
Tell MSan that memory initialized by libz is valid
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Compression.cpp')
-rw-r--r--lib/Support/Compression.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Support/Compression.cpp b/lib/Support/Compression.cpp
index f22d3db9ac..36afa8c06b 100644
--- a/lib/Support/Compression.cpp
+++ b/lib/Support/Compression.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/config.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
@@ -55,9 +56,12 @@ zlib::Status zlib::compress(StringRef InputBuffer,
Status Res = encodeZlibReturnValue(::compress2(
(Bytef *)TmpBuffer.get(), &CompressedSize,
(const Bytef *)InputBuffer.data(), InputBuffer.size(), CLevel));
- if (Res == StatusOK)
+ if (Res == StatusOK) {
CompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
StringRef(TmpBuffer.get(), CompressedSize)));
+ // Tell MSan that memory initialized by zlib is valid.
+ __msan_unpoison(CompressedBuffer.data(), CompressedBuffer.size());
+ }
return Res;
}
@@ -68,9 +72,12 @@ zlib::Status zlib::uncompress(StringRef InputBuffer,
Status Res = encodeZlibReturnValue(
::uncompress((Bytef *)TmpBuffer.get(), (uLongf *)&UncompressedSize,
(const Bytef *)InputBuffer.data(), InputBuffer.size()));
- if (Res == StatusOK)
+ if (Res == StatusOK) {
UncompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
StringRef(TmpBuffer.get(), UncompressedSize)));
+ // Tell MSan that memory initialized by zlib is valid.
+ __msan_unpoison(UncompressedBuffer.data(), UncompressedBuffer.size());
+ }
return Res;
}