xref: /PHP-5.6/ext/gd/tests/github_bug_215.phpt (revision 54293d21)
1--TEST--
2Github #215 (imagefilltoborder stack overflow when invalid pallete index used)
3--SKIPIF--
4<?php
5if (!extension_loaded("gd")) die("skip GD not present");
6if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.2', '<')) {
7    die("skip test requires GD 2.2.2 or higher");
8}
9?>
10--FILE--
11<?php
12$image = imagecreate( 10, 10 );
13$bgd = imagecolorallocate( $image, 0, 0, 0 );
14$border = imagecolorallocate( $image, 255, 0, 0 );
15$fillcolor = imagecolorallocate( $image, 255, 0, 0 );
16
17/* Use unallocated color index */
18imagefilltoborder( $image, 0,0, $border+10, $fillcolor);
19echo "#1 passes\n";
20
21/* Use negative color index */
22imagefilltoborder( $image, 0,0, -$border,  $fillcolor);
23echo "#2 passes\n";
24
25
26/* Use unallocated color index */
27imagefilltoborder( $image, 0,0, $border, $fillcolor+10);
28echo "#3 passes\n";
29
30/* Use negative color index */
31imagefilltoborder( $image, 0,0, $border, -$fillcolor);
32echo "#4 passes\n";
33
34
35/* Use negative color index */
36imagefilltoborder( $image, 0,0, $border+10, $fillcolor+10);
37echo "#5 passes";
38
39
40?>
41--EXPECT--
42#1 passes
43#2 passes
44#3 passes
45#4 passes
46#5 passes
47