From 5c682f6d1ecadf30f39023eaacea3f9408f2e8dd Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 5 Jan 2019 22:36:05 -0500 Subject: Fix image optimization evaluation Don't attempt to pass data through a JPEG filter if we are unable to filter the data. --- qpdf/qpdf.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 1f8aea50..418da7f1 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -3548,16 +3548,7 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) bool ImageOptimizer::evaluate(std::string const& description) { - Pl_Discard d; - Pl_Count c("count", &d); - PointerHolder p = makePipeline(description, &c); - if (p.getPointer() == 0) - { - // message issued by makePipeline - return false; - } - if (! image.pipeStreamData(p.getPointer(), 0, qpdf_dl_specialized, - true, false)) + if (! image.pipeStreamData(0, 0, qpdf_dl_specialized, true)) { QTC::TC("qpdf", "qpdf image optimize no pipeline"); if (o.verbose) @@ -3569,6 +3560,18 @@ ImageOptimizer::evaluate(std::string const& description) } return false; } + Pl_Discard d; + Pl_Count c("count", &d); + PointerHolder p = makePipeline(description, &c); + if (p.getPointer() == 0) + { + // message issued by makePipeline + return false; + } + if (! image.pipeStreamData(p.getPointer(), 0, qpdf_dl_specialized)) + { + return false; + } long long orig_length = image.getDict().getKey("/Length").getIntValue(); if (c.getCount() >= orig_length) { -- cgit v1.2.3-54-g00ecf