[llvm] r180094 - Tell MSan that memory initialized by libz is valid
Alexey Samsonov
samsonov at google.com
Tue Apr 23 05:17:47 PDT 2013
Author: samsonov
Date: Tue Apr 23 07:17:46 2013
New Revision: 180094
URL: http://llvm.org/viewvc/llvm-project?rev=180094&view=rev
Log:
Tell MSan that memory initialized by libz is valid
Modified:
llvm/trunk/lib/Support/Compression.cpp
Modified: llvm/trunk/lib/Support/Compression.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Compression.cpp?rev=180094&r1=180093&r2=180094&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Compression.cpp (original)
+++ llvm/trunk/lib/Support/Compression.cpp Tue Apr 23 07:17:46 2013
@@ -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 In
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
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;
}
More information about the llvm-commits
mailing list