aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_Flate.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-08-26 04:26:53 +0200
committerJay Berkenbilt <ejb@ql.org>2017-08-26 04:26:53 +0200
commit021c229331444aae507186c7b4a54bb1692b5846 (patch)
tree411c5c8f531ccb0380aa112c2d934971c62f2fb9 /libqpdf/Pl_Flate.cc
parentad527a64f93dca12f6aabab2ca99ae5eb352ab4b (diff)
downloadqpdf-021c229331444aae507186c7b4a54bb1692b5846.tar.zst
Fix Pl_Flate memory leak on error (fixes #148)
Diffstat (limited to 'libqpdf/Pl_Flate.cc')
-rw-r--r--libqpdf/Pl_Flate.cc15
1 files changed, 15 insertions, 0 deletions
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<z_stream*>(this->zdata));
+ if (action == a_deflate)
+ {
+ deflateEnd(&zstream);
+ }
+ else
+ {
+ inflateEnd(&zstream);
+ }
+ }
+
delete static_cast<z_stream*>(this->zdata);
this->zdata = 0;
}
@@ -174,6 +188,7 @@ Pl_Flate::finish()
{
err = inflateEnd(&zstream);
}
+ this->initialized = false;
checkError("End", err);
}