diff options
author | Frank Busse <bb0xfb@gmail.com> | 2018-05-16 22:35:54 +0100 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2018-05-22 11:09:22 +0100 |
commit | 1b8bad9dda673f1340b50c39334eb92ee8a8c306 (patch) | |
tree | 98d9e0cd2a094c9ecc36cdbdfa5bd4ff8d8d4e32 | |
parent | b23e2ca61a5a89b66ce38cf02257aba04dd35186 (diff) | |
download | klee-1b8bad9dda673f1340b50c39334eb92ee8a8c306.tar.gz |
CompressionStream: fix sporadic segfaults (uninitialised avail_in)
-rw-r--r-- | lib/Support/CompressionStream.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Support/CompressionStream.cpp b/lib/Support/CompressionStream.cpp index 2e6df113..01fe1352 100644 --- a/lib/Support/CompressionStream.cpp +++ b/lib/Support/CompressionStream.cpp @@ -40,14 +40,19 @@ compressed_fd_ostream::compressed_fd_ostream(const char *Filename, FD = -1; } // Initialize the compression library - strm.zalloc = 0; - strm.zfree = 0; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.next_in = Z_NULL; strm.next_out = buffer; + strm.avail_in = 0; strm.avail_out = BUFSIZE; - deflateInit2(&strm, Z_BEST_COMPRESSION, Z_DEFLATED, 15 | 16, - 8 /* memory usage default, 0 smalles, 9 highest*/, - Z_DEFAULT_STRATEGY); + const auto ret = deflateInit2(&strm, Z_BEST_COMPRESSION, Z_DEFLATED, 31, + 8 /* memory usage default, 0 smallest, 9 highest*/, + Z_DEFAULT_STRATEGY); + if (ret != Z_OK) + ErrorInfo = "Deflate initialisation returned with error: " + std::to_string(ret); } void compressed_fd_ostream::writeFullCompressedData() { @@ -91,7 +96,7 @@ void compressed_fd_ostream::write_impl(const char *Ptr, size_t Size) { // Check if there is still data to compress while (strm.avail_in != 0) { // compress data - int res = deflate(&strm, Z_NO_FLUSH); (void) res; + const auto res __attribute__ ((unused)) = deflate(&strm, Z_NO_FLUSH); assert(res == Z_OK); writeFullCompressedData(); } |