Skip to content

Commit 21389fb

Browse files
authored
[Bugfix] qp_ellipse overflow (#19005)
1 parent ab952c3 commit 21389fb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

quantum/painter/qp_draw_ellipse.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
6767
return false;
6868
}
6969

70-
int16_t aa = ((int16_t)sizex) * ((int16_t)sizex);
71-
int16_t bb = ((int16_t)sizey) * ((int16_t)sizey);
72-
int16_t fa = 4 * ((int16_t)aa);
73-
int16_t fb = 4 * ((int16_t)bb);
70+
int32_t aa = ((int32_t)sizex) * ((int32_t)sizex);
71+
int32_t bb = ((int32_t)sizey) * ((int32_t)sizey);
72+
int32_t fa = 4 * aa;
73+
int32_t fb = 4 * bb;
7474

7575
int16_t dx = 0;
7676
int16_t dy = ((int16_t)sizey);
@@ -83,7 +83,7 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
8383
}
8484

8585
bool ret = true;
86-
for (int16_t delta = (2 * bb) + (aa * (1 - (2 * sizey))); bb * dx <= aa * dy; dx++) {
86+
for (int32_t delta = (2 * bb) + (aa * (1 - (2 * sizey))); bb * dx <= aa * dy; dx++) {
8787
if (!qp_ellipse_helper_impl(device, x, y, dx, dy, filled)) {
8888
ret = false;
8989
break;
@@ -98,7 +98,7 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
9898
dx = sizex;
9999
dy = 0;
100100

101-
for (int16_t delta = (2 * aa) + (bb * (1 - (2 * sizex))); aa * dy <= bb * dx; dy++) {
101+
for (int32_t delta = (2 * aa) + (bb * (1 - (2 * sizex))); aa * dy <= bb * dx; dy++) {
102102
if (!qp_ellipse_helper_impl(device, x, y, dx, dy, filled)) {
103103
ret = false;
104104
break;

0 commit comments

Comments
 (0)