Pass retained argument to CFX_StockFontArray::SetFont() -- in turn, do the same for CPDF_FontGlobals::Set() Bug: pdfium:1843 Change-Id: I5ab6ed6290d980fef9f4c3b9a50be588ee6511c5 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95451 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp index 231a1b5..ada2ce4 100644 --- a/core/fpdfapi/font/cfx_stockfontarray.cpp +++ b/core/fpdfapi/font/cfx_stockfontarray.cpp
@@ -7,6 +7,7 @@ #include "core/fpdfapi/font/cfx_stockfontarray.h" #include <iterator> +#include <utility> #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -35,7 +36,7 @@ } void CFX_StockFontArray::SetFont(CFX_FontMapper::StandardFont index, - const RetainPtr<CPDF_Font>& pFont) { + RetainPtr<CPDF_Font> pFont) { if (index < std::size(m_StockFonts)) - m_StockFonts[index] = pFont; + m_StockFonts[index] = std::move(pFont); }
diff --git a/core/fpdfapi/font/cfx_stockfontarray.h b/core/fpdfapi/font/cfx_stockfontarray.h index 90ae04b..6a1f930 100644 --- a/core/fpdfapi/font/cfx_stockfontarray.h +++ b/core/fpdfapi/font/cfx_stockfontarray.h
@@ -18,8 +18,7 @@ ~CFX_StockFontArray(); RetainPtr<CPDF_Font> GetFont(CFX_FontMapper::StandardFont index) const; - void SetFont(CFX_FontMapper::StandardFont index, - const RetainPtr<CPDF_Font>& pFont); + void SetFont(CFX_FontMapper::StandardFont index, RetainPtr<CPDF_Font> pFont); private: RetainPtr<CPDF_Font> m_StockFonts[14];
diff --git a/core/fpdfapi/font/cpdf_fontglobals.cpp b/core/fpdfapi/font/cpdf_fontglobals.cpp index 0d5cb69..1873a01 100644 --- a/core/fpdfapi/font/cpdf_fontglobals.cpp +++ b/core/fpdfapi/font/cpdf_fontglobals.cpp
@@ -6,6 +6,8 @@ #include "core/fpdfapi/font/cpdf_fontglobals.h" +#include <utility> + #include "core/fpdfapi/cmaps/CNS1/cmaps_cns1.h" #include "core/fpdfapi/cmaps/GB1/cmaps_gb1.h" #include "core/fpdfapi/cmaps/Japan1/cmaps_japan1.h" @@ -74,10 +76,10 @@ void CPDF_FontGlobals::Set(CPDF_Document* pDoc, CFX_FontMapper::StandardFont index, - const RetainPtr<CPDF_Font>& pFont) { + RetainPtr<CPDF_Font> pFont) { if (!pdfium::Contains(m_StockMap, pDoc)) m_StockMap[pDoc] = std::make_unique<CFX_StockFontArray>(); - m_StockMap[pDoc]->SetFont(index, pFont); + m_StockMap[pDoc]->SetFont(index, std::move(pFont)); } void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) {
diff --git a/core/fpdfapi/font/cpdf_fontglobals.h b/core/fpdfapi/font/cpdf_fontglobals.h index 8d66122..e39555b 100644 --- a/core/fpdfapi/font/cpdf_fontglobals.h +++ b/core/fpdfapi/font/cpdf_fontglobals.h
@@ -34,7 +34,7 @@ CFX_FontMapper::StandardFont index); void Set(CPDF_Document* pDoc, CFX_FontMapper::StandardFont index, - const RetainPtr<CPDF_Font>& pFont); + RetainPtr<CPDF_Font> pFont); void SetEmbeddedCharset(CIDSet idx, pdfium::span<const FXCMAP_CMap> map) { m_EmbeddedCharsets[idx] = map;