Commit c65de047 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Use 64-bit values when computing ellipses to avoid overflows.

parent 67a0db3c
...@@ -78,11 +78,11 @@ static int ellipse_first_quadrant( int width, int height, POINT *data ) ...@@ -78,11 +78,11 @@ static int ellipse_first_quadrant( int width, int height, POINT *data )
{ {
const int a = width - 1; const int a = width - 1;
const int b = height - 1; const int b = height - 1;
const int asq = 8 * a * a; const INT64 asq = (INT64)8 * a * a;
const int bsq = 8 * b * b; const INT64 bsq = (INT64)8 * b * b;
int dx = 4 * b * b * (1 - a); INT64 dx = (INT64)4 * b * b * (1 - a);
int dy = 4 * a * a * (1 + (b % 2)); INT64 dy = (INT64)4 * a * a * (1 + (b % 2));
int err = dx + dy + a * a * (b % 2); INT64 err = dx + dy + a * a * (b % 2);
int pos = 0; int pos = 0;
POINT pt; POINT pt;
...@@ -93,7 +93,7 @@ static int ellipse_first_quadrant( int width, int height, POINT *data ) ...@@ -93,7 +93,7 @@ static int ellipse_first_quadrant( int width, int height, POINT *data )
while (pt.x >= width / 2) while (pt.x >= width / 2)
{ {
int e2 = 2 * err; INT64 e2 = 2 * err;
data[pos++] = pt; data[pos++] = pt;
if (e2 >= dx) if (e2 >= dx)
{ {
......
...@@ -754,7 +754,8 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top, ...@@ -754,7 +754,8 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
{ {
RGNOBJ * obj; RGNOBJ * obj;
HRGN hrgn = 0; 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; RECT *rects;
/* Make the dimensions sensible */ /* Make the dimensions sensible */
...@@ -788,10 +789,10 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top, ...@@ -788,10 +789,10 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
a = ellipse_width - 1; a = ellipse_width - 1;
b = ellipse_height - 1; b = ellipse_height - 1;
asq = 8 * a * a; asq = (INT64)8 * a * a;
bsq = 8 * b * b; bsq = (INT64)8 * b * b;
dx = 4 * b * b * (1 - a); dx = (INT64)4 * b * b * (1 - a);
dy = 4 * a * a * (1 + (b % 2)); dy = (INT64)4 * a * a * (1 + (b % 2));
err = dx + dy + a * a * (b % 2); err = dx + dy + a * a * (b % 2);
x = 0; x = 0;
...@@ -802,7 +803,7 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top, ...@@ -802,7 +803,7 @@ HRGN WINAPI CreateRoundRectRgn( INT left, INT top,
while (x <= ellipse_width / 2) while (x <= ellipse_width / 2)
{ {
int e2 = 2 * err; INT64 e2 = 2 * err;
if (e2 >= dx) if (e2 >= dx)
{ {
x++; x++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment