Alexandre Julliard : gdi32: Use 64-bit values when computing ellipses to avoid overflows.
Alexandre Julliard
julliard at winehq.org
Fri Feb 24 10:47:27 CST 2012
Module: wine
Branch: master
Commit: c65de04789ee8c5bf1f6c9d869ac53087af0fcee
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c65de04789ee8c5bf1f6c9d869ac53087af0fcee
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Feb 24 15:55:00 2012 +0100
gdi32: Use 64-bit values when computing ellipses to avoid overflows.
---
dlls/gdi32/dibdrv/graphics.c | 12 ++++++------
dlls/gdi32/region.c | 13 +++++++------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index 3251f36..2f67efe 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -78,11 +78,11 @@ static int ellipse_first_quadrant( int width, int height, POINT *data )
{
const int a = width - 1;
const int b = height - 1;
- const int asq = 8 * a * a;
- const int bsq = 8 * b * b;
- int dx = 4 * b * b * (1 - a);
- int dy = 4 * a * a * (1 + (b % 2));
- int err = dx + dy + a * a * (b % 2);
+ const INT64 asq = (INT64)8 * a * a;
+ const INT64 bsq = (INT64)8 * b * b;
+ INT64 dx = (INT64)4 * b * b * (1 - a);
+ INT64 dy = (INT64)4 * a * a * (1 + (b % 2));
+ INT64 err = dx + dy + a * a * (b % 2);
int pos = 0;
POINT pt;
@@ -93,7 +93,7 @@ static int ellipse_first_quadrant( int width, int height, POINT *data )
while (pt.x >= width / 2)
{
- int e2 = 2 * err;
+ INT64 e2 = 2 * err;
data[pos++] = pt;
if (e2 >= dx)
{
diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c
index 336e56e..231a7cf 100644
--- a/dlls/gdi32/region.c
+++ b/dlls/gdi32/region.c
@@ -754,7 +754,8 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
{
RGNOBJ * obj;
HRGN hrgn = 0;
- int a, b, i, x, y, asq, bsq, dx, dy, err;
+ int a, b, i, x, y;
+ INT64 asq, bsq, dx, dy, err;
RECT *rects;
/* Make the dimensions sensible */
@@ -788,10 +789,10 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
a = ellipse_width - 1;
b = ellipse_height - 1;
- asq = 8 * a * a;
- bsq = 8 * b * b;
- dx = 4 * b * b * (1 - a);
- dy = 4 * a * a * (1 + (b % 2));
+ asq = (INT64)8 * a * a;
+ bsq = (INT64)8 * b * b;
+ dx = (INT64)4 * b * b * (1 - a);
+ dy = (INT64)4 * a * a * (1 + (b % 2));
err = dx + dy + a * a * (b % 2);
x = 0;
@@ -802,7 +803,7 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
while (x <= ellipse_width / 2)
{
- int e2 = 2 * err;
+ INT64 e2 = 2 * err;
if (e2 >= dx)
{
x++;
More information about the wine-cvs
mailing list