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