From 3f80c864d5318d4d80ac811d42c92d8f63e0b5ac Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 16 May 2016 12:03:24 -0700 Subject: Remove some c_str() calls from StringCs in xfa docs. Avoids the risk of possibly getting a non-null terminated buffer if the StringC happened to be created by Mid(), etc. Doesn't seem to happen in practice. Review-Url: https://codereview.chromium.org/1983683003 --- fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp') diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index deba943072..b2f752e8b9 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -625,21 +625,22 @@ void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc, } void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFilePath, + const CFX_WideString& wsFilePath, FX_BOOL bXDP) { if (hDoc != m_pXFADoc) return; + if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) return; + CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) + if (!pEnv) return; - int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; - CFX_ByteString bs = CFX_WideString(wsFilePath).UTF16LE_Encode(); + int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; + CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); if (wsFilePath.IsEmpty()) { - if (!pEnv->GetFormFillInfo() || - pEnv->GetFormFillInfo()->m_pJsPlatform == NULL) + if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) return; CFX_WideString filepath = pEnv->JS_fieldBrowse(); bs = filepath.UTF16LE_Encode(); @@ -649,12 +650,10 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); bs.ReleaseBuffer(len * sizeof(unsigned short)); - - if (pFileHandler == NULL) + if (!pFileHandler) return; CFPDF_FileStream fileWrite(pFileHandler); - CFX_ByteString content; if (fileType == FXFA_SAVEAS_XML) { content = "\r\n"; @@ -725,10 +724,10 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc, } } void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc, - const CFX_WideStringC& wsFilePath) {} + const CFX_WideString& wsFilePath) {} void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, - const CFX_WideStringC& bsURL, + const CFX_WideString& bsURL, FX_BOOL bAppend) { if (hDoc != m_pXFADoc) return; -- cgit v1.2.3