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

Side by Side Diff: core/fpdfapi/fpdf_parser/include/cpdf_stream.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, 4 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_STREAM_H_ 7 #ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_ 8 #define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
9 9
10 #include <set>
11
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
12 #include "core/fxcrt/include/fx_stream.h" 14 #include "core/fxcrt/include/fx_stream.h"
13 15
14 class CPDF_Stream : public CPDF_Object { 16 class CPDF_Stream : public CPDF_Object {
15 public: 17 public:
16 CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); 18 CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
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_Dictionary* GetDict() const override; 23 CPDF_Dictionary* GetDict() const override;
22 CFX_WideString GetUnicodeText() const override; 24 CFX_WideString GetUnicodeText() const override;
23 bool IsStream() const override; 25 bool IsStream() const override;
24 CPDF_Stream* AsStream() override; 26 CPDF_Stream* AsStream() override;
25 const CPDF_Stream* AsStream() const override; 27 const CPDF_Stream* AsStream() const override;
26 28
27 uint32_t GetRawSize() const { return m_dwSize; } 29 uint32_t GetRawSize() const { return m_dwSize; }
28 uint8_t* GetRawData() const { return m_pDataBuf; } 30 uint8_t* GetRawData() const { return m_pDataBuf; }
29 31
30 void SetData(const uint8_t* pData, 32 void SetData(const uint8_t* pData,
31 uint32_t size, 33 uint32_t size,
32 FX_BOOL bCompressed, 34 FX_BOOL bCompressed,
33 FX_BOOL bKeepBuf); 35 FX_BOOL bKeepBuf);
34 36
35 void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); 37 void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
36 void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict); 38 void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict);
37 39
38 FX_BOOL ReadRawData(FX_FILESIZE start_pos, 40 FX_BOOL ReadRawData(FX_FILESIZE start_pos,
39 uint8_t* pBuf, 41 uint8_t* pBuf,
40 uint32_t buf_size) const; 42 uint32_t buf_size) const;
41 43
42 bool IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; } 44 bool IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; }
43 45
44 protected: 46 protected:
45 static const uint32_t kMemoryBasedGenNum = (uint32_t)-1; 47 static const uint32_t kMemoryBasedGenNum = (uint32_t)-1;
46 48
47 ~CPDF_Stream() override; 49 ~CPDF_Stream() override;
50 CPDF_Object* CloneNonCyclic(
51 bool bDirect,
52 std::set<const CPDF_Object*>* pVisited) const override;
48 53
49 void InitStreamInternal(CPDF_Dictionary* pDict); 54 void InitStreamInternal(CPDF_Dictionary* pDict);
50 55
51 CPDF_Dictionary* m_pDict; 56 CPDF_Dictionary* m_pDict;
52 uint32_t m_dwSize; 57 uint32_t m_dwSize;
53 uint32_t m_GenNum; 58 uint32_t m_GenNum;
54 59
55 union { 60 union {
56 uint8_t* m_pDataBuf; 61 uint8_t* m_pDataBuf;
57 IFX_FileRead* m_pFile; 62 IFX_FileRead* m_pFile;
58 }; 63 };
59 }; 64 };
60 65
61 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_ 66 #endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_reference.h ('k') | core/fpdfapi/fpdf_parser/include/cpdf_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698