[Support] Don't initialize buffer allocated by zlib::uncompress
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 3 May 2020 12:52:19 +0000 (14:52 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 3 May 2020 13:01:52 +0000 (15:01 +0200)
This is a somewhat annoying API, but not without precedend in this low
level API.

llvm/lib/Support/Compression.cpp

index 97d5ffa..27d92f0 100644 (file)
@@ -74,10 +74,10 @@ Error zlib::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
 Error zlib::uncompress(StringRef InputBuffer,
                        SmallVectorImpl<char> &UncompressedBuffer,
                        size_t UncompressedSize) {
-  UncompressedBuffer.resize(UncompressedSize);
+  UncompressedBuffer.reserve(UncompressedSize);
   Error E =
       uncompress(InputBuffer, UncompressedBuffer.data(), UncompressedSize);
-  UncompressedBuffer.resize(UncompressedSize);
+  UncompressedBuffer.set_size(UncompressedSize);
   return E;
 }