Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fix GH-8848: imagecopyresized() error refers to the wrong argument
This commit is contained in:
Christoph M. Becker 2022-06-23 15:21:33 +02:00
commit bc8e52f651
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
3 changed files with 36 additions and 5 deletions

4
NEWS
View file

@ -2,7 +2,9 @@ PHP NEWS
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.9 ?? ??? ????, PHP 8.1.9
- GD:
. Fixed bug GH-8848 (imagecopyresized() error refers to the wrong argument).
(cmb)
07 Jul 2022, PHP 8.1.8 07 Jul 2022, PHP 8.1.8

View file

@ -3086,22 +3086,22 @@ PHP_FUNCTION(imagecopyresized)
dstW = DW; dstW = DW;
if (dstW <= 0) { if (dstW <= 0) {
zend_argument_value_error(3, "must be greater than 0"); zend_argument_value_error(7, "must be greater than 0");
RETURN_THROWS(); RETURN_THROWS();
} }
if (dstH <= 0) { if (dstH <= 0) {
zend_argument_value_error(4, "must be greater than 0"); zend_argument_value_error(8, "must be greater than 0");
RETURN_THROWS(); RETURN_THROWS();
} }
if (srcW <= 0) { if (srcW <= 0) {
zend_argument_value_error(5, "must be greater than 0"); zend_argument_value_error(9, "must be greater than 0");
RETURN_THROWS(); RETURN_THROWS();
} }
if (srcH <= 0) { if (srcH <= 0) {
zend_argument_value_error(6, "must be greater than 0"); zend_argument_value_error(10, "must be greater than 0");
RETURN_THROWS(); RETURN_THROWS();
} }

29
ext/gd/tests/gh8848.phpt Normal file
View file

@ -0,0 +1,29 @@
--TEST--
GH-8848 (imagecopyresized() error refers to the wrong argument)
--EXTENSIONS--
gd
--FILE--
<?php
$image1 = imagecreatetruecolor(1, 1);
$image2 = imagecreatetruecolor(1, 1);
$argslist = [
[0, 1, 1, 1],
[1, 0, 1, 1],
[1, 1, 0, 1],
[1, 1, 1, 0],
];
foreach ($argslist as $args) {
try {
imagecopyresized($image1, $image2, 1, 1, 1, 1, ...$args);
} catch (ValueError $ex) {
echo $ex->getMessage(), PHP_EOL;
}
}
?>
--EXPECT--
imagecopyresized(): Argument #7 ($dst_width) must be greater than 0
imagecopyresized(): Argument #8 ($dst_height) must be greater than 0
imagecopyresized(): Argument #9 ($src_width) must be greater than 0
imagecopyresized(): Argument #10 ($src_height) must be greater than 0