forked from old/legacy-imlib2
Fix potential divide-by-zero in imlib_image_draw_ellipse().
Attempting to draw a 2x1 ellipse with e.g. imlib_image_draw_ellipse(x, y, 2, 1) causes a divide-by-zero. It seems happy enough to draw 1x1, 1x2 and 2x2, but not 2x1. Patch by Simon Lees. https://bugs.debian.org/639414
This commit is contained in:
parent
a8ca99a2a4
commit
c94d83ccab
|
@ -71,6 +71,9 @@ __imlib_Ellipse_DrawToData(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(color, bp + len);
|
pfunc(color, bp + len);
|
||||||
|
|
||||||
|
if (dx < 1)
|
||||||
|
dx = 1;
|
||||||
|
|
||||||
dy += b2;
|
dy += b2;
|
||||||
yy -= ((dy << 16) / dx);
|
yy -= ((dy << 16) / dx);
|
||||||
lx--;
|
lx--;
|
||||||
|
@ -123,6 +126,9 @@ __imlib_Ellipse_DrawToData(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(color, bp + len);
|
pfunc(color, bp + len);
|
||||||
|
|
||||||
|
if (dy < 1)
|
||||||
|
dy = 1;
|
||||||
|
|
||||||
dx -= a2;
|
dx -= a2;
|
||||||
xx += ((dx << 16) / dy);
|
xx += ((dx << 16) / dy);
|
||||||
ty++;
|
ty++;
|
||||||
|
@ -222,6 +228,9 @@ __imlib_Ellipse_DrawToData_AA(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(col1, bp + len);
|
pfunc(col1, bp + len);
|
||||||
|
|
||||||
|
if (dx < 1)
|
||||||
|
dx = 1;
|
||||||
|
|
||||||
dy += b2;
|
dy += b2;
|
||||||
yy -= ((dy << 16) / dx);
|
yy -= ((dy << 16) / dx);
|
||||||
lx--;
|
lx--;
|
||||||
|
@ -295,6 +304,9 @@ __imlib_Ellipse_DrawToData_AA(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(col1, bp + len);
|
pfunc(col1, bp + len);
|
||||||
|
|
||||||
|
if (dy < 1)
|
||||||
|
dy = 1;
|
||||||
|
|
||||||
dx -= a2;
|
dx -= a2;
|
||||||
xx += ((dx << 16) / dy);
|
xx += ((dx << 16) / dy);
|
||||||
ty++;
|
ty++;
|
||||||
|
@ -395,6 +407,9 @@ __imlib_Ellipse_FillToData(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(color, bp + len);
|
pfunc(color, bp + len);
|
||||||
|
|
||||||
|
if (dx < 1)
|
||||||
|
dx = 1;
|
||||||
|
|
||||||
dy += b2;
|
dy += b2;
|
||||||
yy -= ((dy << 16) / dx);
|
yy -= ((dy << 16) / dx);
|
||||||
lx--;
|
lx--;
|
||||||
|
@ -453,6 +468,9 @@ __imlib_Ellipse_FillToData(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (((unsigned)by < (unsigned)clh) && (len > 0))
|
if (((unsigned)by < (unsigned)clh) && (len > 0))
|
||||||
sfunc(color, bpp, len);
|
sfunc(color, bpp, len);
|
||||||
|
|
||||||
|
if (dy < 1)
|
||||||
|
dy = 1;
|
||||||
|
|
||||||
dx -= a2;
|
dx -= a2;
|
||||||
xx += ((dx << 16) / dy);
|
xx += ((dx << 16) / dy);
|
||||||
ty++;
|
ty++;
|
||||||
|
@ -556,6 +574,9 @@ __imlib_Ellipse_FillToData_AA(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(col1, bp + len);
|
pfunc(col1, bp + len);
|
||||||
|
|
||||||
|
if (dx < 1)
|
||||||
|
dx = 1;
|
||||||
|
|
||||||
dy += b2;
|
dy += b2;
|
||||||
yy -= ((dy << 16) / dx);
|
yy -= ((dy << 16) / dx);
|
||||||
lx--;
|
lx--;
|
||||||
|
@ -629,6 +650,9 @@ __imlib_Ellipse_FillToData_AA(int xc, int yc, int a, int b, DATA32 color,
|
||||||
if (IN_RANGE(rx, by, clw, clh))
|
if (IN_RANGE(rx, by, clw, clh))
|
||||||
pfunc(col1, bp + len);
|
pfunc(col1, bp + len);
|
||||||
|
|
||||||
|
if (dy < 1)
|
||||||
|
dy = 1;
|
||||||
|
|
||||||
dx -= a2;
|
dx -= a2;
|
||||||
xx += ((dx << 16) / dy);
|
xx += ((dx << 16) / dy);
|
||||||
ty++;
|
ty++;
|
||||||
|
|
Loading…
Reference in New Issue