summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2005-12-30 09:53:05 +0000
committerPierre Joye <pajoye@php.net>2005-12-30 09:53:05 +0000
commite45ec1e460c8151dcdec336e98bb259e343095ce (patch)
tree861bb99395ea6cf4429bd1b29444394be9e13f10
parent974ed3825fc7dda3fbc852905e6986ea798e19d4 (diff)
downloadphp-git-e45ec1e460c8151dcdec336e98bb259e343095ce.tar.gz
- ensure that x1<x2 or y1<y2
-rw-r--r--ext/gd/libgd/gd.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 66214dfe70..b8acd1d155 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -1019,6 +1019,7 @@ void gdImageAABlend (gdImagePtr im)
/* Bresenham as presented in Foley & Van Dam */
void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
{
+ int t;
int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
int wid;
int w, wstart;
@@ -1031,6 +1032,12 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
/* Vertical */
if (x1==x2) {
+ if (y2 < y1) {
+ t = y2;
+ y2 = y1;
+ y1 = t;
+ }
+
for (;y1 <= y2; y1++) {
gdImageSetPixel(im, x1,y1, color);
}
@@ -1039,6 +1046,12 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
/* Horizontal */
if (y1==y2) {
+ if (x2 < x1) {
+ t = x2;
+ x2 = x1;
+ x1 = t;
+ }
+
for (;x1 <= x2; x1++) {
gdImageSetPixel(im, x1,y1, color);
}