diff options
Diffstat (limited to 'core/fxcodec')
-rw-r--r-- | core/fxcodec/codec/fx_codec_jpeg.cpp | 7 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_progress.cpp | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index f7cf291bbf..cf501a99d1 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -417,7 +417,7 @@ CJpegContext::~CJpegContext() { } std::unique_ptr<CCodec_JpegModule::Context> CCodec_JpegModule::Start() { - // Use ordinary pointer until past the fear of a longjump. + // Use ordinary pointer until past the possibility of a longjump. auto* pContext = new CJpegContext(); if (setjmp(pContext->m_JumpMark) == -1) return nullptr; @@ -486,10 +486,7 @@ bool CCodec_JpegModule::StartScanline(Context* pContext, int down_scale) { bool CCodec_JpegModule::ReadScanline(Context* pContext, unsigned char* dest_buf) { auto* ctx = static_cast<CJpegContext*>(pContext); - if (setjmp(ctx->m_JumpMark) == -1) - return false; - - int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); + unsigned int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); return nlines == 1; } diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index c3005bca95..36e22e9f85 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -1879,8 +1879,11 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( GetDownScale(down_scale); // Setting jump marker before calling StartScanLine, since a longjmp to // the marker indicates a fatal error. - if (setjmp(*m_pJpegContext->GetJumpMark()) == -1) + if (setjmp(*m_pJpegContext->GetJumpMark()) == -1) { + m_pJpegContext.reset(); + m_status = FXCODEC_STATUS_ERROR; return FXCODEC_STATUS_ERROR; + } CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); bool startStatus = @@ -2023,6 +2026,14 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { switch (m_imagType) { case FXCODEC_IMAGE_JPG: { CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); + // Setting jump marker before calling ReadScanLine, since a longjmp to + // the marker indicates a fatal error. + if (setjmp(*m_pJpegContext->GetJumpMark()) == -1) { + m_pJpegContext.reset(); + m_status = FXCODEC_STATUS_ERROR; + return FXCODEC_STATUS_ERROR; + } + while (true) { bool readRes = pJpegModule->ReadScanline(m_pJpegContext.get(), m_pDecodeBuf); |