[gnome-shell/wip/fmuellner/border-transparency-fix] st: Avoid integer overflow on unpremultiply
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/border-transparency-fix] st: Avoid integer overflow on unpremultiply
- Date: Thu, 22 Nov 2018 22:32:52 +0000 (UTC)
commit c9a616739128ae7d4e173c592259e0eca87ce10a
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 22 20:41:44 2018 +0100
st: Avoid integer overflow on unpremultiply
When computing the effective border color, we operate on colors with
premultiplied alpha to simplify the calculations, then unpremultiply
the result. However we miss a bounds check in the last check, so any
color component can overflow the allowed maximum of 0xff and shift the
result in unexpected ways.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/305
src/st/st-theme-node-drawing.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index f59065aef..40edd3fa9 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -229,9 +229,9 @@ unpremultiply (ClutterColor *color)
{
if (color->alpha != 0)
{
- color->red = (color->red * 255 + 127) / color->alpha;
- color->green = (color->green * 255 + 127) / color->alpha;
- color->blue = (color->blue * 255 + 127) / color->alpha;
+ color->red = MIN((color->red * 255 + 127) / color->alpha, 255);
+ color->green = MIN((color->green * 255 + 127) / color->alpha, 255);
+ color->blue = MIN((color->blue * 255 + 127) / color->alpha, 255);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]