diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-03-15 17:13:13 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-03-16 02:30:39 +0100 |
commit | 2537d6897ae516d3b4d50f0e2885dc24949841bf (patch) | |
tree | 9bb6f51a83ac354c6ec7637ff700e0d3cdd11ebb /editeng | |
parent | 060a4bf91b0409cda264fd6dec4093b7dd1e4c84 (diff) |
Clip BColor lightness value at 1.0
UBSan build started to fail CppunitTest_sw_ooxmlexport8 with
> /include/tools/color.hxx:59:27: runtime error: value 258.5 is outside the range of representable values of type 'unsigned char'
> #0 0x2ad219182418 in Color::Color(basegfx::BColor const&) /include/tools/color.hxx:59:27
> #1 0x2ad219175e48 in (anonymous namespace)::lcl_compute3DColor(Color, int, int, int) /editeng/source/items/borderline.cxx:50:16
> #2 0x2ad219175574 in editeng::SvxBorderLine::threeDLightColor(Color) /editeng/source/items/borderline.cxx:77:12
> #3 0x2ad21917ea78 in editeng::SvxBorderLine::GetColorOut(bool) const /editeng/source/items/borderline.cxx:573:23
where lcl_compute3DColor had been called with (aMain=rgba(255, 255, 255, 255),
nLight=3, nMedium=40, nDark=83)
Change-Id: I0f4569d9fd9f54164efe395960bcc8a6840e7744
Reviewed-on: https://gerrit.libreoffice.org/51351
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/items/borderline.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx index 70b768a0acc4..ab032bcc043a 100644 --- a/editeng/source/items/borderline.cxx +++ b/editeng/source/items/borderline.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <algorithm> + #include <basegfx/color/bcolor.hxx> #include <basegfx/color/bcolortools.hxx> @@ -43,7 +47,7 @@ namespace { else nCoef = nDark; - double L = hsl.getZ() * 255.0 + nCoef; + double L = std::min(hsl.getZ() * 255.0 + nCoef, 255.0); hsl.setZ( L / 255.0 ); color = basegfx::utils::hsl2rgb( hsl ); |