From 0704e9b8772e89290fa262a044ea0f6db4a58641 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 30 May 2017 10:11:49 -0700 Subject: Release unowned m_pTiffContext before deleting through it Workaround for murky ownership. Note the member will now get cleared as a consequence of Release() Bug: 726887 Change-Id: I3eac3d1aa915497f66a57c5effa892a15d10f583 Reviewed-on: https://pdfium-review.googlesource.com/6079 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fxcodec/codec/ccodec_progressivedecoder.h | 2 ++ core/fxcodec/codec/fx_codec_progress.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 6dd7357b12..42d0ee3aba 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -129,6 +129,8 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, CFX_RetainPtr m_pFile; CFX_UnownedPtr m_pCodecMgr; + + // TODO(tsepez): All these contexts probably should be unique_ptrs. FXJPEG_Context* m_pJpegContext; FXPNG_Context* m_pPngContext; std::unique_ptr m_pGifContext; diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 209a9735f0..dba0e20533 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -302,7 +302,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { if (m_pPngContext) m_pCodecMgr->GetPngModule()->Finish(m_pPngContext); if (m_pTiffContext) - m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext.Get()); + m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext.Release()); FX_Free(m_pSrcBuf); FX_Free(m_pDecodeBuf); FX_Free(m_pSrcPalette); @@ -1219,8 +1219,7 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, m_SrcComponents = 4; m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); if (!ret) { - pTiffModule->DestroyDecoder(m_pTiffContext.Get()); - m_pTiffContext = nullptr; + pTiffModule->DestroyDecoder(m_pTiffContext.Release()); m_status = FXCODEC_STATUS_ERR_FORMAT; return false; } -- cgit v1.2.3