xref: /PHP-8.0/ext/gd/tests/bug38212.phpt (revision 50765075)
1--TEST--
2Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
3--SKIPIF--
4<?php
5        if (!function_exists('imagecopy')) die("skip gd extension not available\n");
6?>
7--FILE--
8<?php
9require __DIR__ . '/func.inc';
10
11$file = __DIR__ . '/bug38212.gd2';
12$im1 = imagecreatetruecolor(10,100);
13imagefill($im1, 0,0, 0xffffff);
14imagegd2($im1, $file);
15
16trycatch_dump(
17    fn() => imagecreatefromgd2part($file, 0,0, -25, 10),
18    fn() => imagecreatefromgd2part($file, 0,0, 10, -25)
19);
20
21unlink($file);
22?>
23--EXPECT--
24!! [ValueError] imagecreatefromgd2part(): Argument #4 ($width) must be greater than or equal to 1
25!! [ValueError] imagecreatefromgd2part(): Argument #5 ($height) must be greater than or equal to 1
26