Commit 5c682f6d1ecadf30f39023eaacea3f9408f2e8dd

Authored by Jay Berkenbilt
1 parent ab536a4e

Fix image optimization evaluation

Don't attempt to pass data through a JPEG filter if we are unable to
filter the data.
Showing 1 changed file with 13 additions and 10 deletions
qpdf/qpdf.cc
@@ -3548,16 +3548,7 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next) @@ -3548,16 +3548,7 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
3548 bool 3548 bool
3549 ImageOptimizer::evaluate(std::string const& description) 3549 ImageOptimizer::evaluate(std::string const& description)
3550 { 3550 {
3551 - Pl_Discard d;  
3552 - Pl_Count c("count", &d);  
3553 - PointerHolder<Pipeline> p = makePipeline(description, &c);  
3554 - if (p.getPointer() == 0)  
3555 - {  
3556 - // message issued by makePipeline  
3557 - return false;  
3558 - }  
3559 - if (! image.pipeStreamData(p.getPointer(), 0, qpdf_dl_specialized,  
3560 - true, false)) 3551 + if (! image.pipeStreamData(0, 0, qpdf_dl_specialized, true))
3561 { 3552 {
3562 QTC::TC("qpdf", "qpdf image optimize no pipeline"); 3553 QTC::TC("qpdf", "qpdf image optimize no pipeline");
3563 if (o.verbose) 3554 if (o.verbose)
@@ -3569,6 +3560,18 @@ ImageOptimizer::evaluate(std::string const&amp; description) @@ -3569,6 +3560,18 @@ ImageOptimizer::evaluate(std::string const&amp; description)
3569 } 3560 }
3570 return false; 3561 return false;
3571 } 3562 }
  3563 + Pl_Discard d;
  3564 + Pl_Count c("count", &d);
  3565 + PointerHolder<Pipeline> p = makePipeline(description, &c);
  3566 + if (p.getPointer() == 0)
  3567 + {
  3568 + // message issued by makePipeline
  3569 + return false;
  3570 + }
  3571 + if (! image.pipeStreamData(p.getPointer(), 0, qpdf_dl_specialized))
  3572 + {
  3573 + return false;
  3574 + }
3572 long long orig_length = image.getDict().getKey("/Length").getIntValue(); 3575 long long orig_length = image.getDict().getKey("/Length").getIntValue();
3573 if (c.getCount() >= orig_length) 3576 if (c.getCount() >= orig_length)
3574 { 3577 {