diff options
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cfdf_document.h | 5 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_unittest.cpp | 26 |
3 files changed, 21 insertions, 13 deletions
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index f83adc1a30..9a13877544 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -11,6 +11,7 @@ #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" #include "core/fpdfapi/parser/cpdf_object.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_Dictionary; @@ -27,12 +28,12 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { ~CFDF_Document() override; bool WriteBuf(CFX_ByteTextBuf& buf) const; - CPDF_Dictionary* GetRoot() const { return m_pRootDict; } + CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); } protected: void ParseStream(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile); - CPDF_Dictionary* m_pRootDict; + CFX_UnownedPtr<CPDF_Dictionary> m_pRootDict; CFX_RetainPtr<IFX_SeekableReadStream> m_pFile; }; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index 8edf062590..f47c859697 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -13,6 +13,7 @@ #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_Dictionary; @@ -204,7 +205,7 @@ class CPDF_DataAvail final { uint32_t m_dwRootObjNum; uint32_t m_dwInfoObjNum; std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized; - CPDF_Object* m_pTrailer; + CFX_UnownedPtr<CPDF_Object> m_pTrailer; bool m_bDocAvail; FX_FILESIZE m_dwHeaderOffset; FX_FILESIZE m_dwLastXRefOffset; diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 1923992d7a..24a989665f 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -82,7 +82,7 @@ class PDFObjectsTest : public testing::Test { // All direct objects. CPDF_Object* objs[] = {boolean_false_obj, boolean_true_obj, number_int_obj, number_float_obj, str_reg_obj, str_spec_obj, - name_obj, m_ArrayObj, m_DictObj, + name_obj, m_ArrayObj.Get(), m_DictObj.Get(), stream_obj, null_obj}; m_DirectObjTypes = { CPDF_Object::BOOLEAN, CPDF_Object::BOOLEAN, CPDF_Object::NUMBER, @@ -179,9 +179,9 @@ class PDFObjectsTest : public testing::Test { std::vector<std::unique_ptr<CPDF_Object>> m_DirectObjs; std::vector<int> m_DirectObjTypes; std::vector<std::unique_ptr<CPDF_Object>> m_RefObjs; - CPDF_Dictionary* m_DictObj; - CPDF_Dictionary* m_StreamDictObj; - CPDF_Array* m_ArrayObj; + CFX_UnownedPtr<CPDF_Dictionary> m_DictObj; + CFX_UnownedPtr<CPDF_Dictionary> m_StreamDictObj; + CFX_UnownedPtr<CPDF_Array> m_ArrayObj; std::vector<CPDF_Object*> m_IndirectObjs; }; @@ -244,23 +244,29 @@ TEST_F(PDFObjectsTest, GetInteger) { TEST_F(PDFObjectsTest, GetDict) { const CPDF_Dictionary* const direct_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, m_DictObj, m_StreamDictObj, nullptr}; + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, m_DictObj.Get(), m_StreamDictObj.Get(), + nullptr}; // Check for direct objects. for (size_t i = 0; i < m_DirectObjs.size(); ++i) EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetDict()); // Check indirect references. - const CPDF_Dictionary* const indirect_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, m_DictObj, m_StreamDictObj}; + const CPDF_Dictionary* const indirect_obj_results[] = {nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + m_DictObj.Get(), + m_StreamDictObj.Get()}; for (size_t i = 0; i < m_RefObjs.size(); ++i) EXPECT_TRUE(Equal(indirect_obj_results[i], m_RefObjs[i]->GetDict())); } TEST_F(PDFObjectsTest, GetArray) { const CPDF_Array* const direct_obj_results[] = { - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, m_ArrayObj, nullptr, nullptr, nullptr}; + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, m_ArrayObj.Get(), nullptr, nullptr, nullptr}; // Check for direct objects. for (size_t i = 0; i < m_DirectObjs.size(); ++i) EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->AsArray()); |