From 39dd5aafb0a92536a8872ac4a9c39a56442c8023 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 23 Apr 2013 12:17:46 +0000 Subject: [PATCH] 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 --- lib/Support/Compression.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Support/Compression.cpp b/lib/Support/Compression.cpp index f22d3db9ac9..36afa8c06b1 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; } -- 2.34.1