Remove assignment to RetainPtr<T> from raw T* types.
This identifies a number of places where we were doing assignments
of needless Gets() of already-retained arguments, at a cost of having
to explicitly call Reset() in a few places. Those should diminish
as more methods are converted to return retained references.
Change-Id: I24b18c93916ddebec0bda896656ea89f259be005
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/98233
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp
index ef9622d..6d6ca0e 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp
@@ -39,7 +39,7 @@
if (!indirect_obj)
return;
- contents_array = indirect_obj->AsMutableArray();
+ contents_array.Reset(indirect_obj->AsMutableArray());
if (contents_array)
contents_array_ = std::move(contents_array);
else if (indirect_obj->IsStream())
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index ac90396..1d1227f 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -520,11 +520,11 @@
ProcessNonbCJK(pBaseDict, pFont->IsBold(), pFont->IsItalic(), basefont,
std::move(pWidths));
} else {
- pFontDict = ProcessbCJK(
+ pFontDict.Reset(ProcessbCJK(
pBaseDict, charset, basefont,
[&pFont, &pEncoding](wchar_t start, wchar_t end, CPDF_Array* widthArr) {
InsertWidthArray1(pFont.get(), pEncoding.get(), start, end, widthArr);
- });
+ }));
}
int italicangle = pFont->GetSubstFontItalicAngle();
FX_RECT bbox = pFont->GetBBox().value_or(FX_RECT());
@@ -619,11 +619,11 @@
ProcessNonbCJK(pBaseDict, pLogFont->lfWeight > FW_MEDIUM,
pLogFont->lfItalic != 0, basefont, std::move(pWidths));
} else {
- pFontDict =
+ pFontDict.Reset(
ProcessbCJK(pBaseDict, eCharset, basefont,
[&hDC](wchar_t start, wchar_t end, CPDF_Array* widthArr) {
InsertWidthArray(hDC, start, end, widthArr);
- });
+ }));
}
auto pBBox = pdfium::MakeRetain<CPDF_Array>();
for (int i = 0; i < 4; i++)
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 4da0e23..0094d40 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -629,7 +629,7 @@
if (pCSObj->IsName()) {
ByteString name = pCSObj->GetString();
if (name != "DeviceRGB" && name != "DeviceGray" && name != "DeviceCMYK") {
- pCSObj = FindResourceObj("ColorSpace", name);
+ pCSObj.Reset(FindResourceObj("ColorSpace", name));
if (pCSObj && pCSObj->IsInline())
pDict->SetFor("ColorSpace", pCSObj->Clone());
}
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 1ed98c1..a4f80fd 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -241,7 +241,7 @@
// If child did not finish, no pages to go, or max level reached, end
if (m_pTreeTraversal.size() != level + 1 || *nPagesToGo == 0 ||
m_bReachedMaxPageLevel) {
- page = pageKid;
+ page.Reset(pageKid);
break;
}
}
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index e046947..1049589 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -458,8 +458,7 @@
if (pBorderArray) {
width = pBorderArray->GetFloatAt(2);
if (pBorderArray->size() == 4) {
- // TODO(tsepez): convert to retained in future CPDF_Dictionary CLs.
- pDashArray = pBorderArray->GetArrayAt(3).Get();
+ pDashArray = pBorderArray->GetArrayAt(3);
if (!pDashArray) {
return;
}
diff --git a/core/fpdfdoc/cpdf_bafontmap.cpp b/core/fpdfdoc/cpdf_bafontmap.cpp
index 4c851ba..fe7ef83 100644
--- a/core/fpdfdoc/cpdf_bafontmap.cpp
+++ b/core/fpdfdoc/cpdf_bafontmap.cpp
@@ -299,16 +299,15 @@
RetainPtr<CPDF_Stream> pStream = pAPDict->GetMutableStreamFor(m_sAPType);
if (!pStream) {
- pStream = m_pDocument->NewIndirect<CPDF_Stream>();
+ pStream.Reset(m_pDocument->NewIndirect<CPDF_Stream>());
pAPDict->SetNewFor<CPDF_Reference>(m_sAPType, m_pDocument.Get(),
pStream->GetObjNum());
}
RetainPtr<CPDF_Dictionary> pStreamDict = pStream->GetMutableDict();
if (!pStreamDict) {
- auto pOwnedDict = m_pDocument->New<CPDF_Dictionary>();
- pStreamDict = pOwnedDict.Get();
- pStream->InitStream({}, std::move(pOwnedDict));
+ pStreamDict = m_pDocument->New<CPDF_Dictionary>();
+ pStream->InitStream({}, pStreamDict);
}
RetainPtr<CPDF_Dictionary> pStreamResList =
@@ -316,7 +315,7 @@
RetainPtr<CPDF_Dictionary> pStreamResFontList =
pStreamResList->GetMutableDictFor("Font");
if (!pStreamResFontList) {
- pStreamResFontList = m_pDocument->NewIndirect<CPDF_Dictionary>();
+ pStreamResFontList.Reset(m_pDocument->NewIndirect<CPDF_Dictionary>());
pStreamResList->SetNewFor<CPDF_Reference>("Font", m_pDocument.Get(),
pStreamResFontList->GetObjNum());
}
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp
index 87b622e..ffcd95f 100644
--- a/core/fpdfdoc/cpdf_generateap.cpp
+++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -944,7 +944,7 @@
RetainPtr<CPDF_Dictionary> pFontDict =
pDRFontDict->GetMutableDictFor(font_name);
if (!pFontDict) {
- pFontDict = pDoc->NewIndirect<CPDF_Dictionary>();
+ pFontDict.Reset(pDoc->NewIndirect<CPDF_Dictionary>());
pFontDict->SetNewFor<CPDF_Name>("Type", "Font");
pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1");
pFontDict->SetNewFor<CPDF_Name>("BaseFont", CFX_Font::kDefaultAnsiFontName);
@@ -1061,7 +1061,7 @@
pAnnotDict->GetOrCreateDictFor(pdfium::annotation::kAP);
RetainPtr<CPDF_Stream> pNormalStream = pAPDict->GetMutableStreamFor("N");
if (!pNormalStream) {
- pNormalStream = pDoc->NewIndirect<CPDF_Stream>();
+ pNormalStream.Reset(pDoc->NewIndirect<CPDF_Stream>());
pAPDict->SetNewFor<CPDF_Reference>("N", pDoc, pNormalStream->GetObjNum());
}
RetainPtr<CPDF_Dictionary> pStreamDict = pNormalStream->GetMutableDict();
@@ -1075,7 +1075,8 @@
if (!ValidateFontResourceDict(pStreamResFontList.Get()))
return;
} else {
- pStreamResFontList = pStreamResList->SetNewFor<CPDF_Dictionary>("Font");
+ pStreamResFontList.Reset(
+ pStreamResList->SetNewFor<CPDF_Dictionary>("Font"));
}
if (!pStreamResFontList->KeyExist(font_name)) {
pStreamResFontList->SetNewFor<CPDF_Reference>(font_name, pDoc,
@@ -1328,7 +1329,8 @@
if (!ValidateFontResourceDict(pStreamResFontList.Get()))
return;
} else {
- pStreamResFontList = pStreamResList->SetNewFor<CPDF_Dictionary>("Font");
+ pStreamResFontList.Reset(
+ pStreamResList->SetNewFor<CPDF_Dictionary>("Font"));
}
if (!pStreamResFontList->KeyExist(font_name)) {
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp
index 3df2f07..7eacf75 100644
--- a/core/fpdfdoc/cpdf_interactiveform.cpp
+++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -267,6 +267,7 @@
return FX_GetCharsetFromCodePage(FX_GetACP());
}
+// TODO(tsepez): return retained reference.
CPDF_Dictionary* InitDict(CPDF_Document* pDocument) {
CPDF_Dictionary* pFormDict = pDocument->NewIndirect<CPDF_Dictionary>();
pDocument->GetMutableRoot()->SetNewFor<CPDF_Reference>(
@@ -569,7 +570,7 @@
RetainPtr<CPDF_Dictionary> pFormDict =
pDocument->GetMutableRoot()->GetMutableDictFor("AcroForm");
if (!pFormDict)
- pFormDict = InitDict(pDocument);
+ pFormDict.Reset(InitDict(pDocument));
FX_Charset charSet = GetNativeCharSet();
ByteString csTemp;
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp
index e5590ee..66fe5bc 100644
--- a/core/fpdfdoc/cpdf_nametree.cpp
+++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -323,7 +323,7 @@
IndexSearchResult result;
result.key = pNames->GetUnicodeTextAt(index);
result.value = std::move(value);
- result.container = pNames.Get(); // TODO(tsepez): retain result.
+ result.container = std::move(pNames);
result.index = index;
return result;
}
@@ -444,14 +444,14 @@
// Retrieve the document's Names dictionary; create it if missing.
RetainPtr<CPDF_Dictionary> pNames = pRoot->GetMutableDictFor("Names");
if (!pNames) {
- pNames = pDoc->NewIndirect<CPDF_Dictionary>();
+ pNames.Reset(pDoc->NewIndirect<CPDF_Dictionary>());
pRoot->SetNewFor<CPDF_Reference>("Names", pDoc, pNames->GetObjNum());
}
// Create the |category| dictionary if missing.
RetainPtr<CPDF_Dictionary> pCategory = pNames->GetMutableDictFor(category);
if (!pCategory) {
- pCategory = pDoc->NewIndirect<CPDF_Dictionary>();
+ pCategory.Reset(pDoc->NewIndirect<CPDF_Dictionary>());
pCategory->SetNewFor<CPDF_Array>("Names");
pNames->SetNewFor<CPDF_Reference>(category, pDoc, pCategory->GetObjNum());
}
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index ee6f548..11e47fe 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -85,7 +85,7 @@
bool bSave = false;
for (auto& kid : m_Kids) {
if (kid.m_Type == Kid::kElement && kid.m_pDict == pDict) {
- kid.m_pElement = pElement;
+ kid.m_pElement.Reset(pElement);
bSave = true;
}
}
diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h
index d227257..bbd4bce 100644
--- a/core/fxcrt/retain_ptr.h
+++ b/core/fxcrt/retain_ptr.h
@@ -92,12 +92,6 @@
return *this;
}
- // Use sparingly, may produce reference count churn.
- RetainPtr& operator=(T* that) {
- Reset(that);
- return *this;
- }
-
bool operator==(const RetainPtr& that) const { return Get() == that.Get(); }
bool operator!=(const RetainPtr& that) const { return !(*this == that); }
diff --git a/core/fxcrt/retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp
index 096c920..4985122 100644
--- a/core/fxcrt/retain_ptr_unittest.cpp
+++ b/core/fxcrt/retain_ptr_unittest.cpp
@@ -212,8 +212,9 @@
EXPECT_EQ(0, obj.release_count());
}
{
+ // Test assignment from wrapped underlying type.
RetainPtr<PseudoRetainable> ptr2;
- ptr2 = ptr.Get(); // Test assignment from underlying type.
+ ptr2 = pdfium::WrapRetain(ptr.Get());
EXPECT_EQ(3, obj.retain_count());
EXPECT_EQ(1, obj.release_count());
}
@@ -235,8 +236,9 @@
EXPECT_EQ(0, obj.release_count());
}
{
+ // Test assignment from wrapped underlying type.
RetainPtr<const PseudoRetainable> ptr2;
- ptr2 = ptr.Get(); // Test assignment from underlying type.
+ ptr2 = pdfium::WrapRetain(ptr.Get());
EXPECT_EQ(3, obj.retain_count());
EXPECT_EQ(1, obj.release_count());
}
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp
index 7cf03dd..cffecbf 100644
--- a/fpdfsdk/cpdfsdk_appstream.cpp
+++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -1829,7 +1829,7 @@
RetainPtr<CPDF_Dictionary> pParentDict;
ByteString key;
if (sAPState.IsEmpty()) {
- pParentDict = dict_.Get();
+ pParentDict = dict_;
key = sAPType;
} else {
pParentDict = dict_->GetOrCreateDictFor(sAPType);
@@ -1845,15 +1845,13 @@
if (!doc->IsModifiedAPStream(pStream.Get())) {
if (pStream)
pOrigStreamDict = pStream->GetMutableDict();
- pStream = doc->CreateModifiedAPStream();
+ pStream.Reset(doc->CreateModifiedAPStream());
pParentDict->SetNewFor<CPDF_Reference>(key, doc, pStream->GetObjNum());
}
RetainPtr<CPDF_Dictionary> pStreamDict = pStream->GetMutableDict();
if (!pStreamDict) {
- auto pNewDict =
- widget_->GetPDFAnnot()->GetDocument()->New<CPDF_Dictionary>();
- pStreamDict = pNewDict.Get();
+ pStreamDict = widget_->GetPDFAnnot()->GetDocument()->New<CPDF_Dictionary>();
pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject");
pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form");
pStreamDict->SetNewFor<CPDF_Number>("FormType", 1);
@@ -1865,7 +1863,7 @@
pStreamDict->SetFor("Resources", pResources->Clone());
}
- pStream->InitStream({}, std::move(pNewDict));
+ pStream->InitStream({}, pStreamDict);
}
pStreamDict->SetMatrixFor("Matrix", widget_->GetMatrix());
pStreamDict->SetRectFor("BBox", widget_->GetRotatedRect());
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index bed7b61..503dc5b 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -684,7 +684,7 @@
if (pColor)
pColor->Clear();
else
- pColor = pAnnotDict->SetNewFor<CPDF_Array>(key);
+ pColor.Reset(pAnnotDict->SetNewFor<CPDF_Array>(key));
pColor->AppendNew<CPDF_Number>(R / 255.f);
pColor->AppendNew<CPDF_Number>(G / 255.f);
@@ -797,7 +797,7 @@
RetainPtr<CPDF_Array> pQuadPointsArray =
GetMutableQuadPointsArrayFromDictionary(pAnnotDict.Get());
if (!pQuadPointsArray)
- pQuadPointsArray = AddQuadPointsArrayToDictionary(pAnnotDict.Get());
+ pQuadPointsArray.Reset(AddQuadPointsArrayToDictionary(pAnnotDict.Get()));
AppendQuadPoints(pQuadPointsArray.Get(), quad_points);
UpdateBBox(pAnnotDict.Get());
return true;
@@ -1120,9 +1120,10 @@
}
// Storing reference to indirect object in annotation's AP
- if (!pApDict)
- pApDict = pAnnotDict->SetNewFor<CPDF_Dictionary>(pdfium::annotation::kAP);
-
+ if (!pApDict) {
+ pApDict.Reset(
+ pAnnotDict->SetNewFor<CPDF_Dictionary>(pdfium::annotation::kAP));
+ }
pApDict->SetNewFor<CPDF_Reference>(modeKey, pDoc,
pNewIndirectStream->GetObjNum());
} else {
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 3fde9c7..8352117 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -705,7 +705,7 @@
if (pRectArray)
pRectArray->Clear();
else
- pRectArray = pAnnotDict->SetNewFor<CPDF_Array>("Rect");
+ pRectArray.Reset(pAnnotDict->SetNewFor<CPDF_Array>("Rect"));
pRectArray->AppendNew<CPDF_Number>(rect.left);
pRectArray->AppendNew<CPDF_Number>(rect.bottom);
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index dd63a6e..c0a0b18 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -220,7 +220,7 @@
sStream += "\nQ";
}
pContentsStream->SetDataAndRemoveFilter(sStream.raw_span());
- pContentsArray = pDocument->NewIndirect<CPDF_Array>();
+ pContentsArray.Reset(pDocument->NewIndirect<CPDF_Array>());
pContentsArray->AppendNew<CPDF_Reference>(pDocument,
pContentsStream->GetObjNum());
pPage->SetNewFor<CPDF_Reference>(pdfium::page_object::kContents, pDocument,
@@ -360,7 +360,7 @@
pFirstObj = pFirstObj->GetMutableDirect();
if (!pFirstObj->IsStream())
continue;
- pAPStream = pFirstObj->AsMutableStream();
+ pAPStream.Reset(pFirstObj->AsMutableStream());
}
}
}
@@ -381,9 +381,8 @@
RetainPtr<CPDF_Object> pObj = pAPStream;
if (pObj->IsInline()) {
- RetainPtr<CPDF_Object> pNew = pObj->Clone();
- pObj = pNew.Get();
- pDocument->AddIndirectObject(std::move(pNew));
+ pObj = pObj->Clone();
+ pDocument->AddIndirectObject(pObj);
}
RetainPtr<CPDF_Dictionary> pObjDict = pObj->GetMutableDict();
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 8ba338e..53459be 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -269,7 +269,7 @@
RetainPtr<CPDF_Dictionary> pNewPages =
pElement ? ToDictionary(pElement->GetMutableDirect()) : nullptr;
if (!pNewPages) {
- pNewPages = dest()->NewIndirect<CPDF_Dictionary>();
+ pNewPages.Reset(dest()->NewIndirect<CPDF_Dictionary>());
pNewRoot->SetNewFor<CPDF_Reference>("Pages", dest(),
pNewPages->GetObjNum());
}
@@ -666,7 +666,7 @@
auto src_page = pdfium::MakeRetain<CPDF_Page>(src(), src_page_dict);
auto xobject = std::make_unique<XObjectContext>();
xobject->dest_doc = dest();
- xobject->xobject = MakeXObjectFromPageRaw(src_page);
+ xobject->xobject.Reset(MakeXObjectFromPageRaw(src_page));
return xobject;
}
diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp
index 7672057..a2d9d04 100644
--- a/fpdfsdk/fpdf_save.cpp
+++ b/fpdfsdk/fpdf_save.cpp
@@ -82,10 +82,10 @@
if (pFormPDFObj->IsReference()) {
RetainPtr<CPDF_Object> pFormDirectObj = pFormPDFObj->GetMutableDirect();
if (pFormDirectObj && pFormDirectObj->IsStream()) {
- pFormStream = pFormDirectObj->AsMutableStream();
+ pFormStream.Reset(pFormDirectObj->AsMutableStream());
}
} else if (pFormPDFObj->IsStream()) {
- pFormStream = pFormPDFObj->AsMutableStream();
+ pFormStream.Reset(pFormPDFObj->AsMutableStream());
}
}
@@ -99,10 +99,10 @@
RetainPtr<CPDF_Object> pDataSetsDirectObj =
pDataSetsRefObj->GetMutableDirect();
if (pDataSetsDirectObj && pDataSetsDirectObj->IsStream()) {
- pDataSetsStream = pDataSetsDirectObj->AsMutableStream();
+ pDataSetsStream.Reset(pDataSetsDirectObj->AsMutableStream());
}
} else if (pDataSetsPDFObj->IsStream()) {
- pDataSetsStream = pDataSetsPDFObj->AsMutableStream();
+ pDataSetsStream.Reset(pDataSetsPDFObj->AsMutableStream());
}
}
// L"datasets"
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 8e5413c..3b64868 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -241,7 +241,7 @@
pContentArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
pContentArray->AppendNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
} else if (pContentObj->IsStream() && !pContentObj->IsInline()) {
- pContentArray = pDoc->NewIndirect<CPDF_Array>();
+ pContentArray.Reset(pDoc->NewIndirect<CPDF_Array>());
pContentArray->AppendNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AppendNew<CPDF_Reference>(pDoc, pContentObj->GetObjNum());
pContentArray->AppendNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
@@ -267,7 +267,7 @@
RetainPtr<CPDF_Dictionary> pDict;
if (pObj->IsDictionary())
- pDict = pObj->AsMutableDictionary();
+ pDict.Reset(pObj->AsMutableDictionary());
else if (CPDF_Stream* pObjStream = pObj->AsMutableStream())
pDict = pObjStream->GetMutableDict();
else
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 4c653af..90d0f68 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -1154,14 +1154,14 @@
CPDF_DictionaryLocker locker(pDest);
for (const auto& it : locker) {
bsName = it.first.AsStringView();
- pDestObj = it.second.Get();
+ pDestObj = it.second;
if (i == index)
break;
i++;
}
wsName = PDF_DecodeText(bsName.raw_span());
} else {
- pDestObj = name_tree->LookupValueAndName(index, &wsName);
+ pDestObj.Reset(name_tree->LookupValueAndName(index, &wsName));
}
if (!pDestObj)
return nullptr;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index e16e7e6..a177ed4 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -285,9 +285,10 @@
if (!pObject) {
for (size_t i = 0; i < count; ++i) {
WideString wsTemp;
+ // TODO(tsepez): return retained object.
CPDF_Object* pTempObject = name_tree->LookupValueAndName(i, &wsTemp);
if (wsTemp == wsName) {
- pObject = pTempObject;
+ pObject.Reset(pTempObject);
break;
}
}