diff options
Diffstat (limited to 'ext/gd')
| -rw-r--r-- | ext/gd/gd.c | 25 | ||||
| -rw-r--r-- | ext/gd/gd_ctx.c | 4 | ||||
| -rw-r--r-- | ext/gd/libgd/gd.c | 14 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_png.c | 2 | ||||
| -rw-r--r-- | ext/gd/libgd/gdft.c | 3 | ||||
| -rw-r--r-- | ext/gd/libgd/xbm.c | 4 | ||||
| -rw-r--r-- | ext/gd/php_gd.h | 4 | ||||
| -rw-r--r-- | ext/gd/tests/bug49600.phpt | 32 | ||||
| -rw-r--r-- | ext/gd/tests/image_type_to_mime_type_basic.phpt | 5 | ||||
| -rw-r--r-- | ext/gd/tests/imagecopyresampled_basic.phpt | 2 | ||||
| -rw-r--r-- | ext/gd/tests/imagedashedline_basic.phpt | 2 | ||||
| -rw-r--r-- | ext/gd/tests/imagefilledpolygon_basic.phpt | 2 | ||||
| -rw-r--r-- | ext/gd/tests/imagefilledpolygon_negative.phpt | 15 | ||||
| -rw-r--r-- | ext/gd/tests/imagepolygon_negative.phpt | 15 | ||||
| -rwxr-xr-x | ext/gd/tests/imagerectangle_basic.phpt | 2 | ||||
| -rwxr-xr-x | ext/gd/tests/imagerectangle_error2.phpt | 2 | ||||
| -rw-r--r-- | ext/gd/tests/libgd00100.phpt | 119 |
17 files changed, 216 insertions, 36 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8853e61a3..8459ac210 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c 282455 2009-06-19 22:15:28Z kalle $ */ +/* $Id: gd.c 294458 2010-02-03 20:42:50Z pajoye $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -3427,7 +3427,10 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have at least 3 points in your array"); RETURN_FALSE; } - + if (npoints <= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must give a positive number of points"); + RETURN_FALSE; + } if (nelem < npoints * 2) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to use %d points in array with only %d points", npoints, nelem/2); RETURN_FALSE; @@ -3880,7 +3883,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int long col = -1, x = -1, y = -1; int str_len, fontname_len, i, brect[8]; double ptsize, angle; - unsigned char *str = NULL, *fontname = NULL; + char *str = NULL, *fontname = NULL; char *error = NULL; int argc = ZEND_NUM_ARGS(); #if HAVE_GD_STRINGFTEX @@ -3942,28 +3945,24 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int { char tmp_font_path[MAXPATHLEN]; - if (VCWD_REALPATH((char *)fontname, tmp_font_path)) { - fontname = (unsigned char *) fontname; - } else { + if (!VCWD_REALPATH(fontname, tmp_font_path)) { fontname = NULL; } } -#else - fontname = (unsigned char *) fontname; #endif - PHP_GD_CHECK_OPEN_BASEDIR((char *)fontname, "Invalid font filename"); + PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename"); #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX if (extended) { - error = gdImageStringFTEx(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str, &strex); + error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex); } else # endif # if HAVE_GD_STRINGFT - error = gdImageStringFT(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str); + error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str); # elif HAVE_GD_STRINGTTF error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str); # endif @@ -4139,7 +4138,7 @@ PHP_FUNCTION(imagepsencodefont) T1_DeleteAllSizes(*f_ind); if (T1_ReencodeFont(*f_ind, enc_vector)) { T1_DeleteEncoding(enc_vector); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't reencode font"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't re-encode font"); RETURN_FALSE; } diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index e4961cf79..13660e6f8 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd_ctx.c 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: gd_ctx.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include "php_gd.h" diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index a0ea6f198..e4e2e0f1a 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2568,7 +2568,7 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c) typedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color); image_line draw_line; - if (!n) { + if (n <= 0) { return; } @@ -2614,14 +2614,14 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) { int i; int y; - int miny, maxy; + int miny, maxy, pmaxy; int x1, y1; int x2, y2; int ind1, ind2; int ints; int fill_color; - if (!n) { + if (n <= 0) { return; } @@ -2658,7 +2658,7 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) maxy = p[i].y; } } - + pmaxy = maxy; /* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */ if (miny < 0) { miny = 0; @@ -2700,13 +2700,13 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) */ if (y >= y1 && y < y2) { im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1; - } else if (y == maxy && y > y1 && y <= y2) { - im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1; + } else if (y == pmaxy && y == y2) { + im->polyInts[ints++] = x2; } } qsort(im->polyInts, ints, sizeof(int), gdCompareInt); - for (i = 0; i < ints; i += 2) { + for (i = 0; i < ints - 1; i += 2) { gdImageLine(im, im->polyInts[i], y, im->polyInts[i + 1], y, fill_color); } } diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c index da5a32f68..52a087e78 100644 --- a/ext/gd/libgd/gd_png.c +++ b/ext/gd/libgd/gd_png.c @@ -145,7 +145,7 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) return NULL; } - if (!png_check_sig (sig, 8)) { /* bad signature */ + if (png_sig_cmp(sig, 0, 8) != 0) { /* bad signature */ return NULL; } diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ffac3ebf6..a3ced0ab1 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -1090,6 +1090,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi if (render) { if (image->format != ft_glyph_format_bitmap && FT_Glyph_To_Bitmap(&image, ft_render_mode_normal, 0, 1)) { + FT_Done_Glyph(image); if (tmpstr) { gdFree(tmpstr); } @@ -1100,7 +1101,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi /* now, draw to our target surface */ bm = (FT_BitmapGlyph) image; - gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6) + bm->left, y + y1 + ((pen.y + 31) >> 6) - bm->top); + gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6), y + y1 + ((pen.y + 31) >> 6) - bm->top); } /* record current glyph index for kerning */ diff --git a/ext/gd/libgd/xbm.c b/ext/gd/libgd/xbm.c index 983163ae5..053d22315 100644 --- a/ext/gd/libgd/xbm.c +++ b/ext/gd/libgd/xbm.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xbm.c 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: xbm.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include <stdio.h> #include <math.h> diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h index d2970ce0c..708b934e8 100644 --- a/ext/gd/php_gd.h +++ b/ext/gd/php_gd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_gd.h 281216 2009-05-27 08:18:24Z pajoye $ */ +/* $Id: php_gd.h 293036 2010-01-03 09:23:27Z sebastian $ */ #ifndef PHP_GD_H #define PHP_GD_H diff --git a/ext/gd/tests/bug49600.phpt b/ext/gd/tests/bug49600.phpt new file mode 100644 index 000000000..068f8f36a --- /dev/null +++ b/ext/gd/tests/bug49600.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #49600 (imageTTFText text shifted right) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagettftext')) die('skip imagettftext() not available'); + if(!function_exists('imagettfbbox')) die('skip imagettfbbox() not available'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$image = imagecreatetruecolor(50, 50); +$color = imagecolorallocate($image, 255, 255, 255); +foreach (array("E", "I", "P", "g", "i", "q") as $c) +{ + $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c); + $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c); + if ( abs($x[0] - $y[0]) > 1 + || abs($x[2] - $y[2]) > 1 + || abs($x[4] - $y[4]) > 1 + || abs($x[6] - $y[6]) > 1 ) { + echo "FAILED: \n"; + var_dump($x); + var_dump($y); + exit; + } +} +echo 'OK'; +?> +--EXPECTF-- +OK
\ No newline at end of file diff --git a/ext/gd/tests/image_type_to_mime_type_basic.phpt b/ext/gd/tests/image_type_to_mime_type_basic.phpt index 5199fd2c4..b81bdbde5 100644 --- a/ext/gd/tests/image_type_to_mime_type_basic.phpt +++ b/ext/gd/tests/image_type_to_mime_type_basic.phpt @@ -2,8 +2,7 @@ image_type_to_mime_type() --SKIPIF-- <?php - if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); - require_once('skipif_imagetype.inc'); + if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); ?> --FILE-- <?php @@ -61,4 +60,4 @@ string(18) "image/vnd.wap.wbmp" string(24) "application/octet-stream" string(9) "image/xbm" -Done image_type_to_mime_type() test
\ No newline at end of file +Done image_type_to_mime_type() test diff --git a/ext/gd/tests/imagecopyresampled_basic.phpt b/ext/gd/tests/imagecopyresampled_basic.phpt index 12ac15511..a0454faf8 100644 --- a/ext/gd/tests/imagecopyresampled_basic.phpt +++ b/ext/gd/tests/imagecopyresampled_basic.phpt @@ -3,7 +3,7 @@ imagecopyresampled() --SKIPIF-- <?php if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); - require_once('skipif_imagetype.inc'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); ?> --FILE-- <?php diff --git a/ext/gd/tests/imagedashedline_basic.phpt b/ext/gd/tests/imagedashedline_basic.phpt index 1d6797520..be65af66d 100644 --- a/ext/gd/tests/imagedashedline_basic.phpt +++ b/ext/gd/tests/imagedashedline_basic.phpt @@ -3,7 +3,7 @@ imagedashedline() --SKIPIF-- <?php if (!function_exists('imagedashedline')) die('skip imagedashedline() not available'); - require_once('skipif_imagetype.inc'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); ?> --FILE-- <?php diff --git a/ext/gd/tests/imagefilledpolygon_basic.phpt b/ext/gd/tests/imagefilledpolygon_basic.phpt index 6871a28b7..ded52da07 100644 --- a/ext/gd/tests/imagefilledpolygon_basic.phpt +++ b/ext/gd/tests/imagefilledpolygon_basic.phpt @@ -3,7 +3,7 @@ imagefilledpolygon() --SKIPIF-- <?php if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); - require_once('skipif_imagetype.inc'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); ?> --FILE-- <?php diff --git a/ext/gd/tests/imagefilledpolygon_negative.phpt b/ext/gd/tests/imagefilledpolygon_negative.phpt new file mode 100644 index 000000000..ced853067 --- /dev/null +++ b/ext/gd/tests/imagefilledpolygon_negative.phpt @@ -0,0 +1,15 @@ +--TEST-- +imagefilledpolygon() with a negative num of points +--SKIPIF-- +<?php + if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); +?> +--FILE-- +<?php +$im = imagecreate(100, 100); +$black = imagecolorallocate($im, 0, 0, 0); +if (imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; +imagedestroy($im); +?> +--EXPECTF-- +Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d diff --git a/ext/gd/tests/imagepolygon_negative.phpt b/ext/gd/tests/imagepolygon_negative.phpt new file mode 100644 index 000000000..bb9010c92 --- /dev/null +++ b/ext/gd/tests/imagepolygon_negative.phpt @@ -0,0 +1,15 @@ +--TEST-- +imagepolygon() with a negative num of points +--SKIPIF-- +<?php + if (!function_exists('imagepolygon')) die('skip imagepolygon() not available'); +?> +--FILE-- +<?php +$im = imagecreate(100, 100); +$black = imagecolorallocate($im, 0, 0, 0); +if (imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; +imagedestroy($im); +?> +--EXPECTF-- +Warning: imagepolygon(): You must give a positive number of points in %s on line %d diff --git a/ext/gd/tests/imagerectangle_basic.phpt b/ext/gd/tests/imagerectangle_basic.phpt index 0574ad35c..f706ee7ab 100755 --- a/ext/gd/tests/imagerectangle_basic.phpt +++ b/ext/gd/tests/imagerectangle_basic.phpt @@ -5,7 +5,7 @@ Ivan Rosolen <contato [at] ivanrosolen [dot] com> #testfest PHPSP on 2009-06-30
--SKIPIF--
<?php
-if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' );
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
?>
--FILE--
<?php
diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt index c6e740214..5fc1914ad 100755 --- a/ext/gd/tests/imagerectangle_error2.phpt +++ b/ext/gd/tests/imagerectangle_error2.phpt @@ -5,7 +5,7 @@ Ivan Rosolen <contato [at] ivanrosolen [dot] com> #testfest PHPSP on 2009-06-30
--SKIPIF--
<?php
-if ( ! extension_loaded('gd') ) die( 'GD not present; skipping test' );
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
?>
--FILE--
<?php
diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt new file mode 100644 index 000000000..abf4ee333 --- /dev/null +++ b/ext/gd/tests/libgd00100.phpt @@ -0,0 +1,119 @@ +--TEST-- +libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(256, 256); + +$white = imagecolorallocatealpha($im, 255, 255, 255, 10); +$black = imagecolorallocatealpha($im, 0, 0, 0, 10); +$red = imagecolorallocatealpha($im, 255, 0, 0, 10); +$green = imagecolorallocatealpha($im, 0, 255, 0, 10); +$blue = imagecolorallocatealpha($im, 0, 0, 255, 10); +$yellow = imagecolorallocatealpha($im, 255, 255, 0, 10); +$cyan = imagecolorallocatealpha($im, 0, 255, 255, 10); +$magenta = imagecolorallocatealpha($im, 255, 0, 255, 10); +$purple = imagecolorallocatealpha($im, 100, 0, 100, 10); + +imagefilledrectangle($im, 0, 0, 255, 255, $white); + +// M (bridge) +$top = 240; +$bot = 255; +$d = 30; +$x = 100; +$points = array( + $x, $top, + $x+2*$d, $top, + $x+2*$d, $bot, + $x+$d, ($top+$bot)/2, + $x, $bot +); +imagefilledpolygon($im, $points, 5, $yellow); + +// left-facing M not on baseline +$top = 40; +$bot = 70; +$left = 120; +$right = 180; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $purple); + +// left-facing M on baseline +$top = 240; +$bot = 270; +$left = 20; +$right = 80; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $magenta); + +// left-facing M on ceiling +$top = -15; +$bot = 15; +$left = 20; +$right = 80; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $blue); + +$d = 30; +$x = 150; +$y = 150; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $green); + +$x = 180; +$y = 225; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $red); + +$x = 225; +$y = 255; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $cyan); + +// M (bridge) not touching bottom boundary +$top = 100; +$bot = 150; +$x = 30; +$points = array( + $x, $top, + $x+2*$d, $top, + $x+2*$d, $bot, + $x+$d, ($top+$bot)/2, + $x, $bot +); +imagefilledpolygon($im, $points, 5, $black); + +ob_start(); +imagepng($im); +$png = ob_get_contents(); +ob_end_clean(); + +echo md5($png); + +imagedestroy($im); +?> +--EXPECTF-- +2e6cf558bb4dadf60c8b608d5f8cda4e |
