diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-11-02 23:49:23 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-11-03 07:33:05 +0100 |
commit | de39e35b21134e9a0f946aabe4859b16a62b248d (patch) | |
tree | 46a28d79c23809b92be0e7e5afce4da97d2b290c /sw | |
parent | 9b9a8f47894760e7a95ed276feeef00d3b1c94d1 (diff) |
Avoid float-cast-overflow
> Testing load file:///~/lo/core//sw/qa/core/data/html/pass/ofz40593-1.html:
> sw/source/filter/html/svxcss1.cxx:2869:44: runtime error: 1.70141e+38 is outside the range of representable values of type 'long'
during CppunitTest_sw_filters_test with test file newly added with
2f01faaf88b6d172d7293f0c9e2a061d99b8ceb5 "ofz#40593 remove Objects from
m_xResizeDrawObjects if deleted during parse"
Change-Id: Ida97b886c254272fd2a506a8d7ad2319fed72dcc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124623
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/svxcss1.cxx | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx index d92d5ea572b6..3ed3a1505135 100644 --- a/sw/source/filter/html/svxcss1.cxx +++ b/sw/source/filter/html/svxcss1.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <algorithm> #include <cmath> #include <memory> #include <stdlib.h> @@ -2866,9 +2867,7 @@ static void ParseCSS1_length( const CSS1Expression *pExpr, break; case CSS1_PERCENTAGE: - rLength = static_cast<tools::Long>(pExpr->GetNumber()); - if( rLength > 100 ) - rLength = 100; + rLength = static_cast<tools::Long>(std::min(pExpr->GetNumber(), 100.0)); rLengthType = SVX_CSS1_LTYPE_PERCENTAGE; break; |