diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-07-27 14:24:02 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-27 18:38:09 +0000 |
commit | 7314af7d04d3fd4f29fff1f0da648944183bd0d0 (patch) | |
tree | 4048c996e6c1db9d1eb31d22cb91c46ede2e8e70 /xfa/fxfa/fm2js/cxfa_fmlexer.h | |
parent | 495d89ff20806b6acdf564f3865b1fb974ccf44a (diff) | |
download | pdfium-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_fmlexer.h')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmlexer.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.h b/xfa/fxfa/fm2js/cxfa_fmlexer.h index 858dc5d988..39031760d9 100644 --- a/xfa/fxfa/fm2js/cxfa_fmlexer.h +++ b/xfa/fxfa/fm2js/cxfa_fmlexer.h @@ -107,14 +107,9 @@ class CXFA_FMLexer { explicit CXFA_FMLexer(const CFX_WideStringC& wsFormcalc); ~CXFA_FMLexer(); - CXFA_FMToken* NextToken(); - bool HasError() const { return m_lexer_error; } + std::unique_ptr<CXFA_FMToken> NextToken(); void SetCurrentLine(uint32_t line) { m_current_line = line; } - void SetToken(std::unique_ptr<CXFA_FMToken> token) { - m_token = std::move(token); - } - const wchar_t* GetPos() { return m_cursor; } void SetPos(const wchar_t* pos) { m_cursor = pos; } @@ -124,6 +119,11 @@ class CXFA_FMLexer { void AdvanceForIdentifier(); void AdvanceForComment(); + void RaiseError() { + m_token.reset(); + m_lexer_error = true; + } + const wchar_t* m_cursor; const wchar_t* const m_end; uint32_t m_current_line; |