summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/xfa_program.cpp
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-11-28 12:31:13 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-28 12:31:13 -0800
commiteb9625c04876c45862fb30e48a4fd6d5998db0e9 (patch)
tree67725226cdf317ff35213da6761dfc0455ec69fb /xfa/fxfa/fm2js/xfa_program.cpp
parentc92e26defaa636b0d2ec9b9de0f88c6153ad7ed3 (diff)
downloadpdfium-eb9625c04876c45862fb30e48a4fd6d5998db0e9.tar.xz
Use unique pointers in CXFA_FMParse
Replaced CXFA_FMParse's returns to be unique pointers to prevent leaks. Review-Url: https://codereview.chromium.org/2530933002
Diffstat (limited to 'xfa/fxfa/fm2js/xfa_program.cpp')
-rw-r--r--xfa/fxfa/fm2js/xfa_program.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp
index 5146a5e129..ac18c15e6d 100644
--- a/xfa/fxfa/fm2js/xfa_program.cpp
+++ b/xfa/fxfa/fm2js/xfa_program.cpp
@@ -6,6 +6,11 @@
#include "xfa/fxfa/fm2js/xfa_program.h"
+#include <utility>
+#include <vector>
+
+#include "third_party/base/ptr_util.h"
+
CXFA_FMProgram::CXFA_FMProgram() {}
CXFA_FMProgram::~CXFA_FMProgram() {}
@@ -15,21 +20,17 @@ int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) {
}
int32_t CXFA_FMProgram::ParseProgram() {
- CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr;
m_parse.NextToken();
- if (!m_pErrorInfo.message.IsEmpty()) {
+ if (!m_pErrorInfo.message.IsEmpty())
return -1;
- }
- expressions = m_parse.ParseTopExpression();
- if (!m_pErrorInfo.message.IsEmpty()) {
- for (int32_t u = 0; u < expressions->GetSize(); ++u)
- delete expressions->GetAt(u);
- delete expressions;
+ std::vector<std::unique_ptr<CXFA_FMExpression>> expressions =
+ m_parse.ParseTopExpression();
+ if (!m_pErrorInfo.message.IsEmpty())
return -1;
- }
- m_globalFunction.reset(
- new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), nullptr, expressions));
+
+ m_globalFunction = pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
+ 1, true, L"", nullptr, std::move(expressions));
return 0;
}