From c452e275e7b5957de1b2f13ab3d1a663f6846081 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Sun, 25 Apr 2004 19:45:02 +0000 Subject: [PATCH] - MFB: Fixed bug #28147 (Crash with drawing anti-alised lines) --- ext/gd/libgd/gd.c | 8 ++++++-- ext/gd/tests/bug28147.phpt | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ext/gd/tests/bug28147.phpt diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 8484c4cf39..7cfcd64f90 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1288,7 +1288,9 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) inc = (dy * 65536) / dx; while ((x >> 16) < x2) { gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF); - gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF); + if ((y >> 16) + 1 < im->sy) { + gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF); + } x += (1 << 16); y += inc; } @@ -1308,7 +1310,9 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) inc = (dx * 65536) / dy; while ((y>>16) < y2) { gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF); - gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF); + if ((x >> 16) + 1 < im->sx) { + gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF); + } x += inc; y += (1<<16); } diff --git a/ext/gd/tests/bug28147.phpt b/ext/gd/tests/bug28147.phpt new file mode 100644 index 0000000000..b3551a6393 --- /dev/null +++ b/ext/gd/tests/bug28147.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #28147 (Crash with anti-aliased line) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Alive -- 2.50.1