summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-07-21 09:11:40 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-07-21 13:20:18 +0200
commit9230c189ebc5bcfd6303bfa7eebcd35488037d00 (patch)
treea6b63ef022535b20ed7747a26dbc95853d18faed /sax
parent5baa40802960eac5c6df897fdbbd59c5e479fca4 (diff)
Use existing rtl_str_toInt64_WithLength
...like it is also already done in LineParser::readInt32 in sdext/source/pdfimport/wrapper/wrapper.cxx (esp. since the code should be changed to use C++17 std::from_chars once that is available in all our baselines), reverting again the introduction of rtl_str_toInt32_WithLength in b1df9c67349cf4cc5be4128d797aefb87f50e38f "[API CHANGE] reduce cost of numeric conversion" Change-Id: I2789f8ec55c8d89150d1c68e6b353a1d2e1d1703 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119301 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sax')
-rw-r--r--sax/source/tools/fastattribs.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 9cec32318108..2512f6296aee 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -196,7 +196,11 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const
for (size_t i = 0; i < maAttributeTokens.size(); ++i)
if (maAttributeTokens[i] == nToken)
{
- rInt = rtl_str_toInt32_WithLength( getFastAttributeValue(i), 10, AttributeValueLength(i) );
+ sal_Int64 n = rtl_str_toInt64_WithLength( getFastAttributeValue(i), 10, AttributeValueLength(i) );
+ if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32) {
+ n = 0;
+ }
+ rInt = n;
return true;
}
return false;
@@ -204,7 +208,11 @@ bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const
sal_Int32 FastAttributeList::getAsIntegerByIndex( sal_Int32 nTokenIndex ) const
{
- return rtl_str_toInt32_WithLength( getFastAttributeValue(nTokenIndex), 10, AttributeValueLength(nTokenIndex) );
+ sal_Int64 n = rtl_str_toInt64_WithLength( getFastAttributeValue(nTokenIndex), 10, AttributeValueLength(nTokenIndex) );
+ if (n < SAL_MIN_INT32 || n > SAL_MAX_INT32) {
+ n = 0;
+ }
+ return n;
}
bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble) const