summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorVladislav Tarakanov <vladislav.tarakanov@bk.ru>2023-07-20 14:45:51 +0400
committerEike Rathke <erack@redhat.com>2023-07-21 00:51:36 +0200
commit3f96f9cdd542bcc05cdd531da3c35bc6f0c2986b (patch)
tree32fd3cee1aeab216b8d6bb83cf95c404ab2eb29b /sal
parent3c63cb1298fc17b71629e04d181244b5acdf8409 (diff)
tdf#139306 Incorrect nDecPlaces value after clamping
nDecPlaces clamping diap changed from +-20 to +-309 and buffer is resized for new value Change-Id: Icb2130891598cf02623bbf5bd0273edab529d124 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153815 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/strtmpl.hxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx
index eece825ec082..bb49cfaf0aa4 100644
--- a/sal/rtl/strtmpl.hxx
+++ b/sal/rtl/strtmpl.hxx
@@ -1540,7 +1540,7 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32
// rtl_math_DecimalPlaces_Max was passed with rtl_math_StringFormat_F or
// others, but we don't want to allocate/deallocate 2GB just to fill it
// with trailing '0' characters..
- nDecPlaces = std::clamp<sal_Int32>(nDecPlaces, -20, 20);
+ nDecPlaces = std::clamp<sal_Int32>(nDecPlaces, -309, 309);
sal_Int32 nDigits = nDecPlaces + 1;
@@ -1566,9 +1566,9 @@ void doubleToString(rtl_tString** pResult, sal_Int32* pResultCapacity, sal_Int32
sal_Int32 nBuf
= (nDigits <= 0 ? std::max<sal_Int32>(nDecPlaces, std::abs(nExp)) : nDigits + nDecPlaces)
+ 10 + (pGroups ? std::abs(nDigits) * 2 : 0);
- // max(nDigits) = max(nDecPlaces) + 1 + max(nExp) + 1 = 20 + 1 + 308 + 1 = 330
- // max(nBuf) = max(nDigits) + max(nDecPlaces) + 10 + max(nDigits) * 2 = 330 * 3 + 20 + 10 = 1020
- assert(nBuf <= 1024);
+ // max(nDigits) = max(nDecPlaces) + 1 + max(nExp) + 1 = 309 + 1 + 308 + 1 = 619
+ // max(nBuf) = max(nDigits) + max(nDecPlaces) + 10 + max(nDigits) * 2 = 619 * 3 + 309 + 10 = 2176
+ assert(nBuf <= 2176);
auto* const pBuf = static_cast<Char_T<rtl_tString>*>(alloca(nBuf * sizeof(Char_T<rtl_tString>)));
auto* p = pBuf;
if (bSign)