diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc index ce4c9ed1..212f7e1d 100644 --- a/libqpdf/Pl_Flate.cc +++ b/libqpdf/Pl_Flate.cc @@ -35,6 +35,20 @@ Pl_Flate::~Pl_Flate() delete [] this->outbuf; this->outbuf = 0; } + + if (this->initialized) + { + z_stream& zstream = *(static_cast(this->zdata)); + if (action == a_deflate) + { + deflateEnd(&zstream); + } + else + { + inflateEnd(&zstream); + } + } + delete static_cast(this->zdata); this->zdata = 0; } @@ -174,6 +188,7 @@ Pl_Flate::finish() { err = inflateEnd(&zstream); } + this->initialized = false; checkError("End", err); }