summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmCTest.cxx15
1 files changed, 7 insertions, 8 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d058ca7..0624b52 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2790,22 +2790,21 @@ bool cmCTest::CompressString(std::string& str)
int ret;
z_stream strm;
- unsigned char* in =
- reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
- // zlib makes the guarantee that this is the maximum output size
- int outSize =
- static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
- unsigned char* out = new unsigned char[outSize];
-
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, -1); // default compression level
if (ret != Z_OK) {
- delete[] out;
return false;
}
+ unsigned char* in =
+ reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
+ // zlib makes the guarantee that this is the maximum output size
+ int outSize =
+ static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
+ unsigned char* out = new unsigned char[outSize];
+
strm.avail_in = static_cast<uInt>(str.size());
strm.next_in = in;
strm.avail_out = outSize;