Index: core/fpdfapi/fpdf_font/fpdf_font.cpp |
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp |
index 1cb67be51f5086b64b6d9dd814879c2660e63c18..a463c15da598f602fa2b6350e894e67a0cb024ce 100644 |
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp |
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp |
@@ -60,10 +60,12 @@ CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const { |
return m_StockFonts[index].get(); |
} |
-void CFX_StockFontArray::SetFont(uint32_t index, CPDF_Font* font) { |
- if (index >= FX_ArraySize(m_StockFonts)) |
- return; |
- m_StockFonts[index].reset(font); |
+CPDF_Font* CFX_StockFontArray::SetFont(uint32_t index, |
+ std::unique_ptr<CPDF_Font> pFont) { |
+ CPDF_Font* result = pFont.get(); |
+ if (index < FX_ArraySize(m_StockFonts)) |
+ m_StockFonts[index] = std::move(pFont); |
+ return result; |
} |
CPDF_FontGlobals::CPDF_FontGlobals() { |
@@ -80,12 +82,12 @@ CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, uint32_t index) { |
return it->second ? it->second->GetFont(index) : nullptr; |
} |
-void CPDF_FontGlobals::Set(CPDF_Document* pDoc, |
- uint32_t index, |
- CPDF_Font* pFont) { |
+CPDF_Font* CPDF_FontGlobals::Set(CPDF_Document* pDoc, |
+ uint32_t index, |
+ std::unique_ptr<CPDF_Font> pFont) { |
if (!pdfium::ContainsKey(m_StockMap, pDoc)) |
m_StockMap[pDoc].reset(new CFX_StockFontArray); |
- m_StockMap[pDoc]->SetFont(index, pFont); |
+ return m_StockMap[pDoc]->SetFont(index, std::move(pFont)); |
} |
void CPDF_FontGlobals::Clear(CPDF_Document* pDoc) { |