summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index b7dc1cbbc7f0..fe81f4c5a7f7 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -433,6 +433,12 @@ void doubleToString(typename T::String ** pResult,
break;
}
+ // Too large values for nDecPlaces make no sense; it might also be
+ // 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::max<sal_Int32>(std::min<sal_Int32>(nDecPlaces, 20), -20);
+
sal_Int32 nDigits = nDecPlaces + 1;
if (eFormat == rtl_math_StringFormat_F)