summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-16 12:03:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-16 12:03:24 -0700
commit3f80c864d5318d4d80ac811d42c92d8f63e0b5ac (patch)
treeefc4acca871bfb2fb1af80f5ee5779ac6ef70034 /fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
parentb22504a8c589ff39a1d6eaa83dcd3ead454d3443 (diff)
downloadpdfium-3f80c864d5318d4d80ac811d42c92d8f63e0b5ac.tar.xz
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
Diffstat (limited to 'fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp')
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp21
1 files changed, 10 insertions, 11 deletions
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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\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;