From 88c5ccc45a3ba26994aaceaaa01adb78f4224760 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 30 May 2022 16:23:28 +0200 Subject: [PATCH] Avoid uninitialized data after getRgbF() even for invalid colors 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 --- src/gui/painting/qcolor.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 265e3496f30..4a04eb39076 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -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);