summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/fx_codec_jpeg.cpp3
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp8
2 files changed, 8 insertions, 3 deletions
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index 4d4adfd817..f7cf291bbf 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -459,9 +459,6 @@ int CCodec_JpegModule::ReadHeader(Context* pContext,
int* nComps) {
#endif // PDF_ENABLE_XFA
auto* ctx = static_cast<CJpegContext*>(pContext);
- if (setjmp(ctx->m_JumpMark) == -1)
- return 1;
-
int ret = jpeg_read_header(&ctx->m_Info, true);
if (ret == JPEG_SUSPENDED)
return 2;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index c9436186ab..c3005bca95 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -1105,6 +1105,14 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
}
m_offSet += size;
pJpegModule->Input(m_pJpegContext.get(), m_pSrcBuf, size);
+ // Setting jump marker before calling ReadHeader, since a longjmp to
+ // the marker indicates a fatal error.
+ if (setjmp(*m_pJpegContext->GetJumpMark()) == -1) {
+ m_pJpegContext.reset();
+ m_status = FXCODEC_STATUS_ERR_FORMAT;
+ return false;
+ }
+
int32_t readResult =
pJpegModule->ReadHeader(m_pJpegContext.get(), &m_SrcWidth,
&m_SrcHeight, &m_SrcComponents, pAttribute);