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

Side by Side Diff: core/src/fpdfdoc/doc_metadata.cpp

Issue 1090463002: Land on Master: Fix two new / free mismatches (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 #include "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fxcrt/fx_xml.h" 8 #include "../../include/fxcrt/fx_xml.h"
9 typedef struct _PDFDOC_METADATA { 9 typedef struct _PDFDOC_METADATA {
10 CPDF_Document *m_pDoc; 10 CPDF_Document *m_pDoc;
(...skipping 10 matching lines...) Expand all
21 "Producer", "Producer", 21 "Producer", "Producer",
22 "Creator", "CreatorTool", 22 "Creator", "CreatorTool",
23 "CreationDate", "CreateDate", 23 "CreationDate", "CreateDate",
24 "ModDate", "ModifyDate", 24 "ModDate", "ModifyDate",
25 "MetadataDate", "MetadataDate" 25 "MetadataDate", "MetadataDate"
26 }; 26 };
27 CPDF_Metadata::CPDF_Metadata() 27 CPDF_Metadata::CPDF_Metadata()
28 { 28 {
29 m_pData = FX_Alloc(PDFDOC_METADATA, 1); 29 m_pData = FX_Alloc(PDFDOC_METADATA, 1);
30 CFX_CMapByteStringToPtr *&pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStri ngMap; 30 CFX_CMapByteStringToPtr *&pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStri ngMap;
31 pStringMap = FX_NEW(CFX_CMapByteStringToPtr); 31 pStringMap = FX_NEW CFX_CMapByteStringToPtr;
32 if (pStringMap != NULL) { 32 if (pStringMap != NULL) {
33 CFX_ByteString bstr; 33 CFX_ByteString bstr;
34 for (int i = 0; i < 18; i += 2) { 34 for (int i = 0; i < 18; i += 2) {
35 bstr = gs_FPDFDOC_Metadata_Titles[i]; 35 bstr = gs_FPDFDOC_Metadata_Titles[i];
36 pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1]) ; 36 pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1]) ;
37 } 37 }
38 } 38 }
39 } 39 }
40 CPDF_Metadata::~CPDF_Metadata() 40 CPDF_Metadata::~CPDF_Metadata()
41 { 41 {
42 FXSYS_assert(m_pData != NULL); 42 FXSYS_assert(m_pData != NULL);
43 CXML_Element *&p = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; 43 CXML_Element *&p = ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt;
44 if (p) { 44 delete p;
45 delete p;
46 }
47 CFX_CMapByteStringToPtr *pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStrin gMap; 45 CFX_CMapByteStringToPtr *pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStrin gMap;
48 if (pStringMap) { 46 if (pStringMap) {
49 pStringMap->RemoveAll(); 47 pStringMap->RemoveAll();
50 FX_Free(pStringMap); 48 delete pStringMap;
51 } 49 }
52 FX_Free(m_pData); 50 FX_Free(m_pData);
53 } 51 }
54 void CPDF_Metadata::LoadDoc(CPDF_Document *pDoc) 52 void CPDF_Metadata::LoadDoc(CPDF_Document *pDoc)
55 { 53 {
56 FXSYS_assert(pDoc != NULL); 54 FXSYS_assert(pDoc != NULL);
57 ((PDFDOC_LPMETADATA)m_pData)->m_pDoc = pDoc; 55 ((PDFDOC_LPMETADATA)m_pData)->m_pDoc = pDoc;
58 CPDF_Dictionary *pRoot = pDoc->GetRoot(); 56 CPDF_Dictionary *pRoot = pDoc->GetRoot();
59 CPDF_Stream *pStream = pRoot->GetStream(FX_BSTRC("Metadata")); 57 CPDF_Stream *pStream = pRoot->GetStream(FX_BSTRC("Metadata"));
60 if (!pStream) { 58 if (!pStream) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return -1; 140 return -1;
143 } 141 }
144 CXML_Element* CPDF_Metadata::GetRoot() const 142 CXML_Element* CPDF_Metadata::GetRoot() const
145 { 143 {
146 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt; 144 return ((PDFDOC_LPMETADATA)m_pData)->m_pXmlElmnt;
147 } 145 }
148 CXML_Element* CPDF_Metadata::GetRDF() const 146 CXML_Element* CPDF_Metadata::GetRDF() const
149 { 147 {
150 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf; 148 return ((PDFDOC_LPMETADATA)m_pData)->m_pElmntRdf;
151 } 149 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698