Use retained locals in cpdf_pagecontentgenerator_unittest.cpp
Skirt spurious warnings from clang-analyzer, but make code better
in the process.
Change-Id: I8408dace869ca18cc42e3c9b1eb61326969b1c27
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100679
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 92cb2ff..8d6aa1f 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -36,12 +36,13 @@
pGen->ProcessPath(buf, pPathObj);
}
- const CPDF_Dictionary* TestGetResource(CPDF_PageContentGenerator* pGen,
- const ByteString& type,
- const ByteString& name) {
+ RetainPtr<const CPDF_Dictionary> TestGetResource(
+ CPDF_PageContentGenerator* pGen,
+ const ByteString& type,
+ const ByteString& name) {
RetainPtr<const CPDF_Dictionary> pResources =
pGen->m_pObjHolder->GetResources();
- return pResources->GetDictFor(type)->GetDictFor(name).Get();
+ return pResources->GetDictFor(type)->GetDictFor(name);
}
void TestProcessText(CPDF_PageContentGenerator* pGen,
@@ -215,7 +216,7 @@
EXPECT_EQ(" gs 1 0 0 1 0 0 cm 1 2 m 3 4 l 5 6 l h B Q\n",
pathString.Last(43));
ASSERT_GT(pathString.GetLength(), 91U);
- const CPDF_Dictionary* externalGS =
+ RetainPtr<const CPDF_Dictionary> externalGS =
TestGetResource(&generator, "ExtGState",
pathString.Substr(48, pathString.GetLength() - 91));
ASSERT_TRUE(externalGS);
@@ -289,13 +290,13 @@
EXPECT_EQ(compareString1, firstString.First(compareString1.GetLength()));
EXPECT_EQ(compareString2, midString.Last(compareString2.GetLength()));
EXPECT_EQ(compareString3, lastString.Last(compareString3.GetLength()));
- const CPDF_Dictionary* externalGS = TestGetResource(
+ RetainPtr<const CPDF_Dictionary> externalGS = TestGetResource(
&generator, "ExtGState",
midString.First(midString.GetLength() - compareString2.GetLength()));
ASSERT_TRUE(externalGS);
EXPECT_EQ(0.5f, externalGS->GetFloatFor("ca"));
EXPECT_EQ(0.8f, externalGS->GetFloatFor("CA"));
- const CPDF_Dictionary* fontDict = TestGetResource(
+ RetainPtr<const CPDF_Dictionary> fontDict = TestGetResource(
&generator, "Font",
lastString.First(lastString.GetLength() - compareString3.GetLength()));
ASSERT_TRUE(fontDict);
@@ -364,7 +365,7 @@
textString.GetLength());
EXPECT_EQ(compareString1, textString.First(compareString1.GetLength()));
EXPECT_EQ(compareString2, textString.Last(compareString2.GetLength()));
- const CPDF_Dictionary* fontDict = TestGetResource(
+ RetainPtr<const CPDF_Dictionary> fontDict = TestGetResource(
&generator, "Font",
textString.Substr(compareString1.GetLength(),
textString.GetLength() - compareString1.GetLength() -