[Pixman] [PATCH] bits: Fix potential divide-by-zero in projective code

2010-12-14 Thread Søren Sandmann
From: Søren Sandmann Pedersen s...@redhat.com

If the homogeneous coordinate is 0, just set the coordinates to 0.
---
 pixman/pixman-bits-image.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 95710b4..36ea0af 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -695,12 +695,20 @@ bits_image_fetch_transformed (pixman_image_t * image,
 {
for (i = 0; i  width; ++i)
{
-   pixman_fixed_t x0, y0;
-
if (!mask || mask[i])
{
-   x0 = ((pixman_fixed_48_16_t)x  16) / w;
-   y0 = ((pixman_fixed_48_16_t)y  16) / w;
+   pixman_fixed_t x0, y0;
+
+   if (w != 0)
+   {
+   x0 = ((pixman_fixed_48_16_t)x  16) / w;
+   y0 = ((pixman_fixed_48_16_t)y  16) / w;
+   }
+   else
+   {
+   x0 = 0;
+   y0 = 0;
+   }
 
buffer[i] =
bits_image_fetch_pixel_filtered (image-bits, x0, y0);
-- 
1.6.0.6

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH] bits: Fix potential divide-by-zero in projective code

2010-07-15 Thread Søren Sandmann
From: Søren Sandmann Pedersen s...@redhat.com

If the homogeneous coordinate is 0, just set the coordinates to 0.
---
 pixman/pixman-bits-image.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 95710b4..36ea0af 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -695,12 +695,20 @@ bits_image_fetch_transformed (pixman_image_t * image,
 {
for (i = 0; i  width; ++i)
{
-   pixman_fixed_t x0, y0;
-
if (!mask || mask[i])
{
-   x0 = ((pixman_fixed_48_16_t)x  16) / w;
-   y0 = ((pixman_fixed_48_16_t)y  16) / w;
+   pixman_fixed_t x0, y0;
+
+   if (w != 0)
+   {
+   x0 = ((pixman_fixed_48_16_t)x  16) / w;
+   y0 = ((pixman_fixed_48_16_t)y  16) / w;
+   }
+   else
+   {
+   x0 = 0;
+   y0 = 0;
+   }
 
buffer[i] =
bits_image_fetch_pixel_filtered (image-bits, x0, y0);
-- 
1.6.0.6

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman