summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-18 11:39:15 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-18 11:39:15 -0700
commit501e8cdc9143d4b1bebd22e7bfdcae4368e459ee (patch)
treebfa380d7dfe06f2fbcf7b59b26a7f61bbb0de07f /xfa/fxfa
parent653951828cf934afb48b57989089a99b38620d02 (diff)
downloadpdfium-501e8cdc9143d4b1bebd22e7bfdcae4368e459ee.tar.xz
Remove Release() from CXFA_ChecksumContext
Review-Url: https://codereview.chromium.org/1991913002
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/xfa_checksum.cpp6
-rw-r--r--xfa/fxfa/app/xfa_ffdoc.cpp2
-rw-r--r--xfa/fxfa/include/xfa_checksum.h5
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.cpp19
4 files changed, 16 insertions, 16 deletions
diff --git a/xfa/fxfa/app/xfa_checksum.cpp b/xfa/fxfa/app/xfa_checksum.cpp
index 195033bfab..1641816550 100644
--- a/xfa/fxfa/app/xfa_checksum.cpp
+++ b/xfa/fxfa/app/xfa_checksum.cpp
@@ -177,9 +177,11 @@ void CXFA_ChecksumContext::FinishChecksum() {
m_pByteContext = NULL;
}
}
-void CXFA_ChecksumContext::GetChecksum(CFX_ByteString& bsChecksum) {
- bsChecksum = m_bsChecksum;
+
+CFX_ByteString CXFA_ChecksumContext::GetChecksum() const {
+ return m_bsChecksum;
}
+
void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) {
if (m_pByteContext) {
CRYPT_SHA1Update(m_pByteContext, bsText.raw_str(), bsText.GetLength());
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index 8297dce9ec..8621430d3f 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -377,7 +377,7 @@ FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage,
CFX_ByteString bsChecksum;
if (pCSContext)
- pCSContext->GetChecksum(bsChecksum);
+ bsChecksum = pCSContext->GetChecksum();
return pExport->Export(pFile, pNode, 0,
bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr);
diff --git a/xfa/fxfa/include/xfa_checksum.h b/xfa/fxfa/include/xfa_checksum.h
index 6c7ea7a04c..f6b13e7cb7 100644
--- a/xfa/fxfa/include/xfa_checksum.h
+++ b/xfa/fxfa/include/xfa_checksum.h
@@ -60,14 +60,13 @@ class CXFA_ChecksumContext {
CXFA_ChecksumContext();
~CXFA_ChecksumContext();
- void Release() { delete this; }
void StartChecksum();
+ void Update(const CFX_ByteStringC& bsText);
FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile,
FX_FILESIZE offset = 0,
size_t size = 0);
void FinishChecksum();
- void GetChecksum(CFX_ByteString& bsChecksum);
- void Update(const CFX_ByteStringC& bsText);
+ CFX_ByteString GetChecksum() const;
protected:
CFX_SAXReader* m_pSAXReader;
diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp
index 01ea1d6fae..3369e59479 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -6,6 +6,8 @@
#include "xfa/fxfa/parser/xfa_parser_imp.h"
+#include <memory>
+
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
@@ -565,24 +567,21 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
m_pXMLParser->m_dwCheckStatus != 0x03) {
return NULL;
}
- CXFA_ChecksumContext* pChecksum = new CXFA_ChecksumContext;
+ std::unique_ptr<CXFA_ChecksumContext> pChecksum(new CXFA_ChecksumContext);
pChecksum->StartChecksum();
pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0],
m_pXMLParser->m_nSize[0]);
pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1],
m_pXMLParser->m_nSize[1]);
pChecksum->FinishChecksum();
- CFX_ByteString bsCheck;
- pChecksum->GetChecksum(bsCheck);
- pChecksum->Release();
- if (bsCheck != wsChecksum.UTF8Encode()) {
- return NULL;
- }
+ CFX_ByteString bsCheck = pChecksum->GetChecksum();
+ if (bsCheck != wsChecksum.UTF8Encode())
+ return nullptr;
pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form);
- if (!pNode) {
- return NULL;
- }
+ if (!pNode)
+ return nullptr;
+
pNode->SetCData(XFA_ATTRIBUTE_Name,
XFA_GetPacketByIndex(XFA_PACKET_Form)->pName);
pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC());