summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-05-22 11:23:29 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-05-22 14:00:11 +0200
commit94ec9e15d5c418ff767dbf92c5d49914e5a55dd5 (patch)
tree8722759ab2970bff5f21a8ee427d5ccc6b6dd221 /src
parent162ee6f4e888050f36f23997eaa5fc215b80e75a (diff)
downloadqtlocation-mapboxgl-94ec9e15d5c418ff767dbf92c5d49914e5a55dd5.tar.gz
[core] fix hang when parsing very large angles for hue in hsl colors
Diffstat (limited to 'src')
-rw-r--r--src/csscolorparser/csscolorparser.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/csscolorparser/csscolorparser.cpp b/src/csscolorparser/csscolorparser.cpp
index 4d1c6a3d65..106dae6cef 100644
--- a/src/csscolorparser/csscolorparser.cpp
+++ b/src/csscolorparser/csscolorparser.cpp
@@ -185,7 +185,6 @@ optional<Color> parse(const std::string& css_str) {
// Convert to lowercase.
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
-
for (const auto& namedColor : namedColors) {
if (str == namedColor.name) {
return { namedColor.color };
@@ -262,8 +261,9 @@ optional<Color> parse(const std::string& css_str) {
}
float h = parseFloat(params[0]) / 360.0f;
- while (h < 0.0f) h++;
- while (h > 1.0f) h--;
+ float i;
+ // Normalize the hue to [0..1[
+ h = std::modf(h, &i);
// NOTE(deanm): According to the CSS spec s/l should only be
// percentages, but we don't bother and let float or percentage.