summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_dataavail.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-16 11:12:21 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-16 11:12:21 -0700
commit4540fbaa718b0b06e076321e0e1a61e80a161499 (patch)
tree0264321d30996058a3b120cff7707e93562bb425 /fpdfsdk/fpdf_dataavail.cpp
parent3421d2bd1f12dc51916df1869ec8beab8711faec (diff)
downloadpdfium-4540fbaa718b0b06e076321e0e1a61e80a161499.tar.xz
Get CPDF_Parser out of the document creation business.
Precursor to someday using possibly subclassed documents. Review-Url: https://codereview.chromium.org/2248123002
Diffstat (limited to 'fpdfsdk/fpdf_dataavail.cpp')
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index b7b47f86a1..3cc7fc0347 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -136,18 +136,19 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
if (!pDataAvail)
return nullptr;
- CPDF_Parser* pParser = new CPDF_Parser;
+ std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser);
pParser->SetPassword(password);
- CPDF_Parser::Error error =
- pParser->StartAsyncParse(pDataAvail->m_pDataAvail->GetFileRead());
+
+ std::unique_ptr<CPDF_Document> pDocument(new CPDF_Document(pParser.get()));
+ CPDF_Parser::Error error = pParser->StartAsyncParse(
+ pDataAvail->m_pDataAvail->GetFileRead(), std::move(pDocument));
if (error != CPDF_Parser::SUCCESS) {
- delete pParser;
ProcessParseError(error);
return nullptr;
}
pDataAvail->m_pDataAvail->SetDocument(pParser->GetDocument());
CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
- return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
+ return FPDFDocumentFromCPDFDocument(pParser.release()->GetDocument());
}
DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {