Use StringTo{Float,Double}() in more places
Replace various strtod(), strtof(), and wcstod() calls.
Change-Id: I2db0463c75e6843bc51bdea5d19c26f38bd8546a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/128475
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 796768b..8197dea 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -1099,8 +1099,7 @@
if (fxv8::IsString(extracted)) {
ByteString bsValue = fxv8::ReentrantToByteStringHelper(pIsolate, extracted);
- // SAFETY: ByteStrings are always NUL-terminated.
- return UNSAFE_BUFFERS(strtof(bsValue.c_str(), nullptr));
+ return StringToFloat(bsValue.AsStringView());
}
return fxv8::ReentrantToFloatHelper(pIsolate, extracted);
@@ -1119,8 +1118,7 @@
if (fxv8::IsString(extracted)) {
ByteString bsValue = fxv8::ReentrantToByteStringHelper(pIsolate, extracted);
- // SAFETY: ByteStrings are always NUL_terminated.
- return UNSAFE_BUFFERS(strtod(bsValue.c_str(), nullptr));
+ return StringToDouble(bsValue.AsStringView());
}
return fxv8::ReentrantToDoubleHelper(pIsolate, extracted);
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 92cff00..6183f0d 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -6,8 +6,6 @@
#include "xfa/fxfa/parser/cxfa_localevalue.h"
-#include <wchar.h>
-
#include <memory>
#include <utility>
#include <vector>
@@ -15,6 +13,7 @@
#include "core/fxcrt/cfx_datetime.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/span.h"
#include "xfa/fgas/crt/cfgas_stringformatter.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -224,8 +223,7 @@
return 0;
}
- // SAFETY: WideStrings are always terminated.
- return UNSAFE_BUFFERS(wcstod(m_wsValue.c_str(), nullptr));
+ return StringToDouble(m_wsValue.AsStringView());
}
CFX_DateTime CXFA_LocaleValue::GetDate() const {