[Pixman] [PATCH 2/3] stress-test: Avoid overflows in clip rectangles

Søren Sandmann sandmann at cs.au.dk
Mon Jul 30 13:34:27 PDT 2012


From: Søren Sandmann Pedersen <ssp at redhat.com>

The rectangles in the clip region set in set_general_properties()
would sometimes overflow, which would lead to messages like these:

      *** BUG ***
      In pixman_region32_union_rect: Invalid rectangle passed
      Set a breakpoint on '_pixman_log_error' to debug

when the micro version number of pixman is even.

Fix this by detecting the overflow and clamping such that the x2/y2
coordinates are less than INT32_MAX.
---
 test/stress-test.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/test/stress-test.c b/test/stress-test.c
index 54ab1c5..edcfe09 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -468,6 +468,11 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map)
 		width = lcg_rand_n (image->bits.width) - x + 10;
 		height = lcg_rand_n (image->bits.height) - y + 10;
 
+		if (width + x < x)
+		    width = INT32_MAX - x;
+		if (height + y < y)
+		    height = INT32_MAX - y;
+		
 		pixman_region32_union_rect (
 		    &region, &region, x, y, width, height);
 	    }
-- 
1.7.4



More information about the Pixman mailing list