[Pixman] [PATCH 2/3] gradient-walker: Fix wraparound when using NONE/PAD
Andrea Canciani
ranma42 at gmail.com
Thu Jan 5 02:42:17 PST 2012
When the pos parameter cannot be represented as int32_t (i.e. it is
outside [INT32_MIN, INT32_MAX]), truncating it to 32 bits can make it
belong to the [0,1] range.
For the NONE and PAD repeat modes, this can result in an incorrect
color.
---
pixman/pixman-gradient-walker.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/pixman/pixman-gradient-walker.c b/pixman/pixman-gradient-walker.c
index ae917e6..e0aa3a4 100644
--- a/pixman/pixman-gradient-walker.c
+++ b/pixman/pixman-gradient-walker.c
@@ -65,7 +65,14 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
}
else
{
- x = pos;
+ /* Clamp to [-1,2] to make sure that the position can be
+ * represented as int32_t without affecting the result. */
+ if (pos < -pixman_fixed_1)
+ x = -pixman_fixed_1;
+ else if (pos > pixman_int_to_fixed (2))
+ x = pixman_int_to_fixed (2);
+ else
+ x = pos;
}
for (n = 0; n < count; n++)
--
1.7.5.4
More information about the Pixman
mailing list