diff --git a/include/dpp/zlibcontext.h b/include/dpp/zlibcontext.h index fa8c6092f7..a1a7f48350 100644 --- a/include/dpp/zlibcontext.h +++ b/include/dpp/zlibcontext.h @@ -48,7 +48,7 @@ class zlibcontext { * @brief Zlib stream struct. The actual type is defined in zlib.h * so is only defined in the implementation file. */ - std::unique_ptr d_stream{}; + z_stream* d_stream{}; /** * @brief ZLib decompression buffer. diff --git a/src/dpp/zlibcontext.cpp b/src/dpp/zlibcontext.cpp index 6631c6b223..b789dd9009 100644 --- a/src/dpp/zlibcontext.cpp +++ b/src/dpp/zlibcontext.cpp @@ -26,17 +26,19 @@ namespace dpp { zlibcontext::zlibcontext() { - d_stream = std::make_unique(); - std::memset(d_stream.get(), 0, sizeof(z_stream)); - int error = inflateInit(d_stream.get()); + d_stream = new z_stream(); + std::memset(d_stream, 0, sizeof(z_stream)); + int error = inflateInit(d_stream); if (error != Z_OK) { + delete d_stream; throw dpp::connection_exception((exception_error_code)error, "Can't initialise stream compression!"); } decomp_buffer.resize(DECOMP_BUFFER_SIZE); } zlibcontext::~zlibcontext() { - inflateEnd(d_stream.get()); + inflateEnd(d_stream); + delete d_stream; } exception_error_code zlibcontext::decompress(const std::string& buffer, std::string& decompressed) { @@ -47,7 +49,7 @@ exception_error_code zlibcontext::decompress(const std::string& buffer, std::str do { d_stream->next_out = static_cast(decomp_buffer.data()); d_stream->avail_out = DECOMP_BUFFER_SIZE; - int ret = inflate(d_stream.get(), Z_NO_FLUSH); + int ret = inflate(d_stream, Z_NO_FLUSH); size_t have = DECOMP_BUFFER_SIZE - d_stream->avail_out; switch (ret) {