diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-21 14:23:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-21 23:59:31 +0000 |
commit | 2ce749a428d1df2c659ecfdaf2e151dd07d3f1b3 (patch) | |
tree | d9b2a6352ea96cec5e4a71e4fceb6edf62f50df1 /basegfx | |
parent | cb3108f860065928552a86cf8acc4b3a95718ecf (diff) |
cid#1517814 Calling risky function
Change-Id: I0451ac0375ad5a29a5bf65ebcc028ae44c43d934
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144688
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/color/bcolormodifier.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index bd6157f373d5..f27ffcc9aaf0 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -18,10 +18,10 @@ */ #include <sal/config.h> - #include <algorithm> - +#include <float.h> #include <basegfx/color/bcolormodifier.hxx> +#include <comphelper/random.hxx> namespace basegfx { @@ -304,17 +304,21 @@ namespace basegfx if(1.0 <= mfRandomPart) { // full randomized color - const double fMul(1.0 / RAND_MAX); - return basegfx::BColor(rand() * fMul, rand() * fMul, rand() * fMul); + return basegfx::BColor( + comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)), + comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX)), + comphelper::rng::uniform_real_distribution(0.0, nextafter(1.0, DBL_MAX))); } // mixed color const double fMulA(1.0 - mfRandomPart); - const double fMulB(mfRandomPart / RAND_MAX); return basegfx::BColor( - aSourceColor.getRed() * fMulA + rand() * fMulB, - aSourceColor.getGreen() * fMulA + rand() * fMulB, - aSourceColor.getBlue() * fMulA + rand() * fMulB); + aSourceColor.getRed() * fMulA + + comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX)), + aSourceColor.getGreen() * fMulA + + comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX)), + aSourceColor.getBlue() * fMulA + + comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX))); } ::basegfx::BColor BColorModifierStack::getModifiedColor(const ::basegfx::BColor& rSource) const |