diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/Pl_Flate.cc | 50 | ||||
-rw-r--r-- | libqpdf/QPDF.cc | 11 |
2 files changed, 38 insertions, 23 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(); } diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 56555261..bda87f01 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -2206,7 +2206,7 @@ QPDF::pipeStreamData(int objid, int generation, warn(e); } } - catch (std::runtime_error& e) + catch (std::exception& e) { if (! suppress_warnings) { @@ -2218,7 +2218,14 @@ QPDF::pipeStreamData(int objid, int generation, QUtil::int_to_string(generation) + ": " + e.what())); } } - pipeline->finish(); + try + { + pipeline->finish(); + } + catch (std::exception&) + { + // ignore + } return success; } |