diff options
Diffstat (limited to 'llvm/lib/Support/Compression.cpp')
-rw-r--r-- | llvm/lib/Support/Compression.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Support/Compression.cpp b/llvm/lib/Support/Compression.cpp index b54613e92b8..7453071f1df 100644 --- a/llvm/lib/Support/Compression.cpp +++ b/llvm/lib/Support/Compression.cpp @@ -62,16 +62,23 @@ zlib::Status zlib::compress(StringRef InputBuffer, return Res; } +zlib::Status zlib::uncompress(StringRef InputBuffer, char *UncompressedBuffer, + size_t &UncompressedSize) { + Status Res = encodeZlibReturnValue( + ::uncompress((Bytef *)UncompressedBuffer, (uLongf *)&UncompressedSize, + (const Bytef *)InputBuffer.data(), InputBuffer.size())); + // Tell MemorySanitizer that zlib output buffer is fully initialized. + // This avoids a false report when running LLVM with uninstrumented ZLib. + __msan_unpoison(UncompressedBuffer, UncompressedSize); + return Res; +} + zlib::Status zlib::uncompress(StringRef InputBuffer, SmallVectorImpl<char> &UncompressedBuffer, size_t UncompressedSize) { UncompressedBuffer.resize(UncompressedSize); - Status Res = encodeZlibReturnValue(::uncompress( - (Bytef *)UncompressedBuffer.data(), (uLongf *)&UncompressedSize, - (const Bytef *)InputBuffer.data(), InputBuffer.size())); - // Tell MemorySanitizer that zlib output buffer is fully initialized. - // This avoids a false report when running LLVM with uninstrumented ZLib. - __msan_unpoison(UncompressedBuffer.data(), UncompressedSize); + Status Res = + uncompress(InputBuffer, UncompressedBuffer.data(), UncompressedSize); UncompressedBuffer.resize(UncompressedSize); return Res; } |