[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>
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index 3a69467..f977194 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -304,8 +304,10 @@
 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)) {