cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug28147.phpt
| From: | Derick Rethans | Date: | Sun, 25 Apr 2004 19:45:04 +0000 |
| Subject: | cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug28147.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-27185@lists.php.net to get a copy of this message | ||
derick Sun Apr 25 15:45:04 2004 EDT
Modified files:
/php-src/ext/gd/tests bug28147.phpt
/php-src/ext/gd/libgd gd.c
Log:
- MFB: Fixed bug #28147 (Crash with drawing anti-alised lines)
http://cvs.php.net/diff.php/php-src/ext/gd/tests/bug28147.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/gd/tests/bug28147.phpt
diff -u /dev/null php-src/ext/gd/tests/bug28147.phpt:1.2
--- /dev/null Sun Apr 25 15:45:02 2004
+++ php-src/ext/gd/tests/bug28147.phpt Sun Apr 25 15:45:02 2004
@@ -0,0 +1,27 @@
+--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
http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.77&r2=1.78&ty=u
Index: php-src/ext/gd/libgd/gd.c
diff -u php-src/ext/gd/libgd/gd.c:1.77 php-src/ext/gd/libgd/gd.c:1.78
--- php-src/ext/gd/libgd/gd.c:1.77 Mon Mar 29 13:20:33 2004
+++ php-src/ext/gd/libgd/gd.c Sun Apr 25 15:45:02 2004
@@ -1288,7 +1288,9 @@
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 @@
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);
}