diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-30 11:37:51 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-30 19:18:58 +0000 |
commit | a69665d11d4eaf5f2d17a46e6be7b43f6c0dbfbe (patch) | |
tree | 2a04260c86c166f0a0a9fc299d8ec6c825809c3e | |
parent | 1c5e98c6fdd664eda5e6d04835e55125a2117970 (diff) | |
download | pdfium-a69665d11d4eaf5f2d17a46e6be7b43f6c0dbfbe.tar.xz |
Avoid one more instance of the anti-pattern in 706346.
Need to have a function taking a const CFX_RetainPtr<X>& 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 <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | core/fxge/dib/fx_dib_main.cpp | 9 |
1 files 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_DIBitmap> CFX_DIBSource::FlipImage(bool bXFlip, CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr<CFX_DIBSource>& pSrc) { if (pSrc->GetBuffer()) { + CFX_RetainPtr<CFX_DIBSource> pOldSrc(pSrc); m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); - 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(); } |