aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_Flate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/Pl_Flate.cc')
-rw-r--r--libqpdf/Pl_Flate.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index 297cdac7..535383c9 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -157,28 +157,36 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush)
void
Pl_Flate::finish()
{
- if (this->outbuf)
+ try
{
- if (this->initialized)
- {
- z_stream& zstream = *(static_cast<z_stream*>(this->zdata));
- unsigned char buf[1];
- buf[0] = '\0';
- handleData(buf, 0, Z_FINISH);
- int err = Z_OK;
- if (action == a_deflate)
- {
- err = deflateEnd(&zstream);
- }
- else
- {
- err = inflateEnd(&zstream);
- }
- checkError("End", err);
- }
-
- delete [] this->outbuf;
- this->outbuf = 0;
+ if (this->outbuf)
+ {
+ if (this->initialized)
+ {
+ z_stream& zstream = *(static_cast<z_stream*>(this->zdata));
+ unsigned char buf[1];
+ buf[0] = '\0';
+ handleData(buf, 0, Z_FINISH);
+ int err = Z_OK;
+ if (action == a_deflate)
+ {
+ err = deflateEnd(&zstream);
+ }
+ else
+ {
+ err = inflateEnd(&zstream);
+ }
+ checkError("End", err);
+ }
+
+ delete [] this->outbuf;
+ this->outbuf = 0;
+ }
+ }
+ catch (std::exception& e)
+ {
+ this->getNext()->finish();
+ throw e;
}
this->getNext()->finish();
}