aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-06 04:36:05 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-06 04:37:49 +0100
commit5c682f6d1ecadf30f39023eaacea3f9408f2e8dd (patch)
tree0313af4e6a9b4b578ebb98a493b465e698109077
parentab536a4e559c5e1bad44bc0e0780d696368d0c57 (diff)
downloadqpdf-5c682f6d1ecadf30f39023eaacea3f9408f2e8dd.tar.zst
Fix image optimization evaluation
Don't attempt to pass data through a JPEG filter if we are unable to filter the data.
-rw-r--r--qpdf/qpdf.cc23
1 files 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<Pipeline> 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<Pipeline> 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)
{