File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ PHP NEWS
1818 . Fixed bug GH-17609 (Typo in error message: Dom\NO_DEFAULT_NS instead of
1919 Dom\HTML_NO_DEFAULT_NS). (nielsdos)
2020
21+ - GD:
22+ . Fixed bug GH-17703 (imagescale with both width and height negative values
23+ triggers only an Exception on width). (David Carlier)
24+
2125- MBString:
2226 . Fixed bug GH-17503 (Undefined float conversion in mb_convert_variables).
2327 (cmb)
Original file line number Diff line number Diff line change @@ -627,6 +627,9 @@ PHP 8.4 UPGRADE NOTES
627627 . DOMDocument::registerNodeClass() now has a tentative return type of true.
628628 Previously, the return type was bool but only true could be returned in practice.
629629
630+ - GD:
631+ . imagescale now throws a ValueError when both width and height arguments are negative.
632+
630633- Hash:
631634 . Changed the return type of hash_update() to true. It was already the case that only
632635 true could be returned, but the stub was not updated yet.
Original file line number Diff line number Diff line change @@ -3981,6 +3981,11 @@ PHP_FUNCTION(imagescale)
39813981
39823982 im = php_gd_libgdimageptr_from_zval_p (IM );
39833983
3984+ if (tmp_h < 0 && tmp_w < 0 ) {
3985+ zend_value_error ("Argument #2 ($width) and argument #3 ($height) cannot be both negative" );
3986+ RETURN_THROWS ();
3987+ }
3988+
39843989 if (tmp_h < 0 || tmp_w < 0 ) {
39853990 /* preserve ratio */
39863991 long src_x , src_y ;
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-17703 both width and height value being negative triggers ValueError on width.
3+ --EXTENSIONS--
4+ gd
5+ --FILE--
6+ <?php
7+
8+ $ img = imagecreatetruecolor ( 256 , 1 );
9+
10+ try {
11+ imagescale ($ img , -1 , -1 , 0 );
12+ } catch (\ValueError $ e ) {
13+ echo $ e ->getMessage ();
14+ }
15+ ?>
16+ --EXPECT--
17+ Argument #2 ($width) and argument #3 ($height) cannot be both negative
You can’t perform that action at this time.
0 commit comments