]> Pileus Git - ~andy/gtk/commit
Avoid integer overflow in gdk_rectangle_intersect
authorAlexander Larsson <alexl@redhat.com>
Fri, 22 Jan 2010 08:34:57 +0000 (09:34 +0100)
committerAlexander Larsson <alexl@redhat.com>
Fri, 22 Jan 2010 08:41:17 +0000 (09:41 +0100)
commit3c618f2f1f2181cb86226515e894f235f35b5fef
tree4597ca8808e55b3422800f48cf3008e1ce400257
parent97a1a28bcb926e9e8f0f738f09f7ffe95dcbfdf5
Avoid integer overflow in gdk_rectangle_intersect

If e.g. the right edge of the leftmost rectangle is near MIN_INT, and
the left edge of the rightmost rectangle is large then subtracting these
can lead to an integer overflow, making the resultant "width" falsely
positive, thus returning a very wide result instead of the expected
no-intersection result.

We avoid the overflow by not doing the subtraction unless we know the
result will be positive. There are still risks for overflow if x + width
or y + width is larger than MAXINT, but we won't ever overflow for valid
rects now.

This may fix #607687
gdk/gdkrectangle.c