Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: core/fpdfapi/fpdf_parser/include/cpdf_reference.h

Issue 2250533002: Fix stack overflow in object Clone() functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase again Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_ 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_
8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_ 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_
9 9
10 #include <set>
11
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
11 13
12 class CPDF_IndirectObjectHolder; 14 class CPDF_IndirectObjectHolder;
13 15
14 class CPDF_Reference : public CPDF_Object { 16 class CPDF_Reference : public CPDF_Object {
15 public: 17 public:
16 CPDF_Reference(CPDF_IndirectObjectHolder* pDoc, int objnum); 18 CPDF_Reference(CPDF_IndirectObjectHolder* pDoc, int objnum);
17 19
18 // CPDF_Object. 20 // CPDF_Object.
19 Type GetType() const override; 21 Type GetType() const override;
20 CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override; 22 CPDF_Object* Clone() const override;
21 CPDF_Object* GetDirect() const override; 23 CPDF_Object* GetDirect() const override;
22 CFX_ByteString GetString() const override; 24 CFX_ByteString GetString() const override;
23 FX_FLOAT GetNumber() const override; 25 FX_FLOAT GetNumber() const override;
24 int GetInteger() const override; 26 int GetInteger() const override;
25 CPDF_Dictionary* GetDict() const override; 27 CPDF_Dictionary* GetDict() const override;
26 28
27 // TODO(weili): check whether GetUnicodeText() and GetArray() are needed. 29 // TODO(weili): check whether GetUnicodeText() and GetArray() are needed.
28 bool IsReference() const override; 30 bool IsReference() const override;
29 CPDF_Reference* AsReference() override; 31 CPDF_Reference* AsReference() override;
30 const CPDF_Reference* AsReference() const override; 32 const CPDF_Reference* AsReference() const override;
31 33
32 CPDF_IndirectObjectHolder* GetObjList() const { return m_pObjList; } 34 CPDF_IndirectObjectHolder* GetObjList() const { return m_pObjList; }
33 uint32_t GetRefObjNum() const { return m_RefObjNum; } 35 uint32_t GetRefObjNum() const { return m_RefObjNum; }
34 36
35 void SetRef(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum); 37 void SetRef(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum);
36 38
37 protected: 39 protected:
38 ~CPDF_Reference() override; 40 ~CPDF_Reference() override;
41 CPDF_Object* CloneNonCyclic(
42 bool bDirect,
43 std::set<const CPDF_Object*>* pVisited) const override;
39 CPDF_Object* SafeGetDirect() const { 44 CPDF_Object* SafeGetDirect() const {
40 CPDF_Object* obj = GetDirect(); 45 CPDF_Object* obj = GetDirect();
41 if (!obj || obj->IsReference()) 46 if (!obj || obj->IsReference())
42 return nullptr; 47 return nullptr;
43 return obj; 48 return obj;
44 } 49 }
45 50
46 CPDF_IndirectObjectHolder* m_pObjList; 51 CPDF_IndirectObjectHolder* m_pObjList;
47 uint32_t m_RefObjNum; 52 uint32_t m_RefObjNum;
48 }; 53 };
49 54
50 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_ 55 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_REFERENCE_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_object.h ('k') | core/fpdfapi/fpdf_parser/include/cpdf_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698