xref: /PHP-7.4/ext/gd/tests/bug74435.phpt (revision 8dc4f4dc)
1--TEST--
2Bug #74435 (Buffer over-read into uninitialized memory)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6?>
7--FILE--
8<?php
9$im = imagecreatefromgif(__DIR__ . DIRECTORY_SEPARATOR . 'bug74435.gif');
10var_dump($im);
11$width = imagesx($im);
12$height = imagesy($im);
13for ($i = 0; $i < $width; $i += 16) {
14    for ($j = 0; $j < $height; $j += 16) {
15        if (($index = imagecolorat($im, $i, $j)) >= 2) {
16            list($red, $green, $blue, $alpha) = array_values(imagecolorsforindex($im, $index));
17            if ($red !== 0 || $green !== 0 || $blue !== 0 || $alpha !== 0) {
18                echo "unexpected color at ($i, $j)\n";
19            }
20        }
21    }
22}
23?>
24===DONE===
25--EXPECTF--
26resource(%d) of type (gd)
27===DONE===
28