diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-18 06:06:39 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-20 19:37:11 -0500 |
commit | 2610323545cb5ee3dff0b7d7da505a1cd1e01b73 (patch) | |
tree | 29c48a0a79de6a8a02361ad14d0c4cef3b7676bc | |
parent | 3479050216a65e3ef6e966a8e801415145261216 (diff) |
Fix divide-by-zero in set_lum().
When (l - min) or (max - l) are zero, simply set all the channels to
the limit, 0 in the case of (l - min), and a in the case of (max - l).
-rw-r--r-- | pixman/pixman-combine.c.template | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template index 56dfb430..f5dd8e12 100644 --- a/pixman/pixman-combine.c.template +++ b/pixman/pixman-combine.c.template @@ -959,15 +959,33 @@ set_lum (comp4_t dest[3], comp4_t src[3], comp4_t sa, comp4_t lum) if (min < 0) { - tmp[0] = l + (tmp[0] - l) * l / (l - min); - tmp[1] = l + (tmp[1] - l) * l / (l - min); - tmp[2] = l + (tmp[2] - l) * l / (l - min); + if (l - min == 0.0) + { + tmp[0] = 0; + tmp[1] = 0; + tmp[2] = 0; + } + else + { + tmp[0] = l + (tmp[0] - l) * l / (l - min); + tmp[1] = l + (tmp[1] - l) * l / (l - min); + tmp[2] = l + (tmp[2] - l) * l / (l - min); + } } if (max > a) { - tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l); - tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l); - tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l); + if (max - l == 0.0) + { + tmp[0] = a; + tmp[1] = a; + tmp[2] = a; + } + else + { + tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l); + tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l); + tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l); + } } dest[0] = tmp[0] * MASK + 0.5; |