diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-06-14 19:55:22 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-14 19:55:22 +0000 |
commit | e90469e4c9b22ff912c70ec70392cf607fb1ad57 (patch) | |
tree | 87af6b4e4bedb0ee86ada4bb21f2466a02e50f43 /xfa | |
parent | bb3d6313f278feee76f5fba17feff3aee65fb928 (diff) | |
download | pdfium-e90469e4c9b22ff912c70ec70392cf607fb1ad57.tar.xz |
[formcalc] Calculate length of string when calling FXSYS_wcstof
When calling the FXSYS_wctof method we currently pass in -1 from
AdvanceForNumber. This tells the method to calculate the string length.
This can be slow for a formcalc string with a lot of numbers.
This CL changes the call to pass in the length of remaining data in the
original string. This takes the MSAN runtime of the case in the linked
bug from ~21seconds to ~500ms. The debug runtime goes from ~2s to
~500ms.
Bug: chromium:846104
Change-Id: Idbd19a728160f35982e21c0d97567fbbeefe667a
Reviewed-on: https://pdfium-review.googlesource.com/35210
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmlexer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp index 3a694675b7..f9771940b6 100644 --- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp @@ -304,8 +304,10 @@ CXFA_FMToken CXFA_FMLexer::NextToken() { CXFA_FMToken CXFA_FMLexer::AdvanceForNumber() { // This will set end to the character after the end of the number. int32_t used_length = 0; - if (m_cursor) - FXSYS_wcstof(const_cast<wchar_t*>(m_cursor), -1, &used_length); + if (m_cursor) { + FXSYS_wcstof(const_cast<wchar_t*>(m_cursor), m_end - m_cursor, + &used_length); + } const wchar_t* end = m_cursor + used_length; if (used_length == 0 || !end || FXSYS_iswalpha(*end)) { |