summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-14 17:10:06 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-10-14 17:10:06 -0700
commite1177425a656f915657f948d965193a019702a52 (patch)
treeb3213672a9af719ffe6b9b519a828d587886f289 /core/include
parent35d720aff01c5ea778c16ac1e31c56f68490f10b (diff)
downloadpdfium-e1177425a656f915657f948d965193a019702a52.tar.xz
Store the address of the page data map's value for proper referencing.
CPDF_Pattern objects are counted and maintained in m_PatternedMap. When a CPDF_Pattern object "pattern" is deleted, it's address is marked as NULL in m_PatternMap. This patch stores the address of CPDF_Pattern's adderss in all objects that references "pattern", to ensure valid referencing after deletion. BUG=416319, 419976, 418392 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/656753002
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/fpdf_resource.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 7bad01501a..54e1c97ee7 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -38,6 +38,28 @@ class CFX_DIBitmap;
typedef struct FT_FaceRec_* FXFT_Face;
class CFX_CTTGSUBTable;
class CPDF_Page;
+
+template <class ObjClass> class CPDF_CountedObject : public CFX_Object
+{
+public:
+ ObjClass m_Obj;
+ FX_DWORD m_nCount;
+};
+typedef CPDF_CountedObject<CPDF_Font*> CPDF_CountedFont;
+typedef CPDF_CountedObject<CPDF_ColorSpace*> CPDF_CountedColorSpace;
+typedef CPDF_CountedObject<CPDF_Pattern*> CPDF_CountedPattern;
+typedef CPDF_CountedObject<CPDF_Image*> CPDF_CountedImage;
+typedef CPDF_CountedObject<CPDF_IccProfile*> CPDF_CountedICCProfile;
+typedef CPDF_CountedObject<CPDF_StreamAcc*> CPDF_CountedStreamAcc;
+
+
+typedef CFX_MapPtrTemplate<CPDF_Dictionary*, CPDF_CountedFont*> CPDF_FontMap;
+typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedColorSpace*> CPDF_ColorSpaceMap;
+typedef CFX_MapPtrTemplate<CPDF_Object*, CPDF_CountedPattern*> CPDF_PatternMap;
+typedef CFX_MapPtrTemplate<FX_DWORD, CPDF_CountedImage*> CPDF_ImageMap;
+typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedICCProfile*> CPDF_IccProfileMap;
+typedef CFX_MapPtrTemplate<CPDF_Stream*, CPDF_CountedStreamAcc*> CPDF_FontFileMap;
+
#define PDFFONT_TYPE1 1
#define PDFFONT_TRUETYPE 2
#define PDFFONT_TYPE3 3
@@ -790,8 +812,9 @@ public:
int m_ShadingType;
- CPDF_ColorSpace* m_pCS;
+ CPDF_ColorSpace* m_pCS; // Still keep m_pCS as some CPDF_ColorSpace (name object) are not managed as counted objects. Refer to CPDF_DocPageData::GetColorSpace.
+ CPDF_CountedColorSpace* m_pCountedCS;
CPDF_Function* m_pFunctions[4];