Skip to content

Commit

Permalink
Avoid uninitialized data after getRgbF() even for invalid colors
Browse files Browse the repository at this point in the history
The other getXxxF() functions will fill in values in the out
parameters even in case of Invalid cspec. So make getRgbF() behave
consistently, and return the same values as getRedF() etc. do in that
case.

Change-Id: Ibb8b0c9526b43ce61118c04b479328dbe88d0419
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
  • Loading branch information
aavit committed Jun 1, 2022
1 parent f9df851 commit 88c5ccc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/gui/painting/qcolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,15 +1261,12 @@ void QColor::getRgbF(float *r, float *g, float *b, float *a) const
if (!r || !g || !b)
return;

if (cspec == Invalid)
return;

if (cspec != Rgb && cspec != ExtendedRgb) {
if (cspec != Invalid && cspec != Rgb && cspec != ExtendedRgb) {
toRgb().getRgbF(r, g, b, a);
return;
}

if (cspec == Rgb) {
if (cspec == Rgb || cspec == Invalid) {
*r = ct.argb.red / float(USHRT_MAX);
*g = ct.argb.green / float(USHRT_MAX);
*b = ct.argb.blue / float(USHRT_MAX);
Expand Down

0 comments on commit 88c5ccc

Please sign in to comment.