From a69665d11d4eaf5f2d17a46e6be7b43f6c0dbfbe Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 30 Mar 2017 11:37:51 -0700 Subject: Avoid one more instance of the anti-pattern in 706346. Need to have a function taking a const CFX_RetainPtr& reference as an argument, assign a different object to a m_ variable of the same type in the function, continue to use the reference after the assignment, and call the function elsewhere with the same m_ variable as the argument while having no other RetainPtrs to the object. Unclear if it is called in this manner, but the first three points hold, so be proactive. Change-Id: I0ece4d7da0b8cf5f3079c53fa612ca07e9632502 Reviewed-on: https://pdfium-review.googlesource.com/3377 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fxge/dib/fx_dib_main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 8a97d342b5..32b7c0be52 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -1400,14 +1400,15 @@ CFX_RetainPtr CFX_DIBSource::FlipImage(bool bXFlip, CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr& pSrc) { if (pSrc->GetBuffer()) { + CFX_RetainPtr pOldSrc(pSrc); m_pBitmap = pdfium::MakeRetain(); - if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), - pSrc->GetFormat(), pSrc->GetBuffer())) { + if (!m_pBitmap->Create(pOldSrc->GetWidth(), pOldSrc->GetHeight(), + pOldSrc->GetFormat(), pOldSrc->GetBuffer())) { m_pBitmap.Reset(); return; } - m_pBitmap->SetPalette(pSrc->GetPalette()); - m_pBitmap->SetAlphaMask(pSrc->m_pAlphaMask); + m_pBitmap->SetPalette(pOldSrc->GetPalette()); + m_pBitmap->SetAlphaMask(pOldSrc->m_pAlphaMask); } else { m_pBitmap = pSrc->Clone(); } -- cgit v1.2.3