summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-27 14:24:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 18:38:09 +0000
commit7314af7d04d3fd4f29fff1f0da648944183bd0d0 (patch)
tree4048c996e6c1db9d1eb31d22cb91c46ede2e8e70 /xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
parent495d89ff20806b6acdf564f3865b1fb974ccf44a (diff)
downloadpdfium-7314af7d04d3fd4f29fff1f0da648944183bd0d0.tar.xz
Rewrite FMLexer to use nullptr for errors
This CL rewrites how FMLexer returns errors, instead of having a flag that gets flipped and needs to be checked, it now returns nullptr for NextToken() when an error occurs. The Lexer's behaviour has also been changed to only return nullptr once an error has occurred, instead of advancing the lexing on further calls. FMParse now checks the returned value from the lexer instead of testing the error flag on the parser object. For any operation that might cause the error state of the parser to change, i.e. consuming a token, an error check has been added. In the event this check fails the related function returns nullptr. This will cause the parse to short circuit and exit. BUG=pdfium:814 Change-Id: I669012c4732c18d13009be7cd7bf1ae682950904 Reviewed-on: https://pdfium-review.googlesource.com/8950 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index bea1f32d23..81942e274e 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -6065,7 +6065,7 @@ bool CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
CXFA_FMParse parser(wsFormcalc);
std::unique_ptr<CXFA_FMFunctionDefinition> func = parser.Parse();
- if (parser.HasError())
+ if (!func || parser.HasError())
return false;
if (!func->ToJavaScript(*wsJavascript))