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;
}
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);
}
--- /dev/null
+--TEST--
+Bug #28147 (Crash with anti-aliased line)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+//
+// This script will generate a Seg Fault on Linux
+//
+$im = imagecreatetruecolor(300, 300);
+$w = imagecolorallocate($im, 255, 255, 255);
+$red = imagecolorallocate($im, 255, 0, 0);
+
+imagefilledrectangle($im,0,0,299,299,$w);
+
+imageantialias($im,true);
+imageline($im, 299, 299, 0, 299, $red);
+
+imagedestroy($im);
+
+echo "Alive\n";
+?>
+--EXPECT--
+Alive