From 911c33f0256d0b5f80a91fc56b8eac537f7356d8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 26 Apr 2020 12:01:22 +0200 Subject: [PATCH] Move the `maybeValidDimensions` check, used with JPEG images, to occur earlier (PR 11523 follow-up) Given that the `NativeImageDecoder.{isSupported, isDecodable}` methods require both dictionary lookups *and* ColorSpace parsing, in hindsight it actually seems more reasonable to the `JpegStream.maybeValidDimensions` checks *first*. --- src/core/evaluator.js | 4 ++-- src/core/image_utils.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 763bcb724..9fbf0ab1f 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -549,13 +549,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { !softMask && !mask && image instanceof JpegStream && + image.maybeValidDimensions && NativeImageDecoder.isSupported( image, this.xref, resources, this.pdfFunctionFactory - ) && - image.maybeValidDimensions + ) ) { // These JPEGs don't need any more processing so we can just send it. return this.handler diff --git a/src/core/image_utils.js b/src/core/image_utils.js index 6fddb543d..cdd04fb8d 100644 --- a/src/core/image_utils.js +++ b/src/core/image_utils.js @@ -36,13 +36,13 @@ class NativeImageDecoder { canDecode(image) { return ( image instanceof JpegStream && + image.maybeValidDimensions && NativeImageDecoder.isDecodable( image, this.xref, this.resources, this.pdfFunctionFactory - ) && - image.maybeValidDimensions + ) ); }