File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ PHP NEWS
2222 . Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
2323 small value). (David Carlier)
2424
25+ - GD:
26+ . Fixed bug GH-20511 (imagegammacorrect out of range input/output values).
27+ (David Carlier)
28+
2529- LibXML:
2630 . Fix some deprecations on newer libxml versions regarding input
2731 buffer/parser handling. (ndossche)
Original file line number Diff line number Diff line change @@ -2286,11 +2286,21 @@ PHP_FUNCTION(imagegammacorrect)
22862286 RETURN_THROWS ();
22872287 }
22882288
2289+ if (!zend_finite (input )) {
2290+ zend_argument_value_error (2 , "must be finite" );
2291+ RETURN_THROWS ();
2292+ }
2293+
22892294 if (output <= 0.0 ) {
22902295 zend_argument_value_error (3 , "must be greater than 0" );
22912296 RETURN_THROWS ();
22922297 }
22932298
2299+ if (!zend_finite (output )) {
2300+ zend_argument_value_error (3 , "must be finite" );
2301+ RETURN_THROWS ();
2302+ }
2303+
22942304 gamma = input / output ;
22952305
22962306 im = php_gd_libgdimageptr_from_zval_p (IM );
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-20551: (imagegammacorrect out of range input/output value)
3+ --EXTENSIONS--
4+ gd
5+ --FILE--
6+ <?php
7+ $ im = imagecreate (64 , 32 );
8+
9+ $ gammas = [
10+ [NAN , 1.0 ],
11+ [-NAN , 1.0 ],
12+ [INF , 1.0 ],
13+ [-INF , 1.0 ],
14+ [1.0 , NAN ],
15+ [1.0 , -NAN ],
16+ [1.0 , INF ],
17+ [1.0 , -INF ],
18+ ];
19+
20+ foreach ($ gammas as $ gamma ) {
21+ try {
22+ imagegammacorrect ($ im , $ gamma [0 ], $ gamma [1 ]);
23+ } catch (\ValueError $ e ) {
24+ echo $ e ->getMessage (), PHP_EOL ;
25+ }
26+ }
27+ ?>
28+ --EXPECT--
29+ imagegammacorrect(): Argument #2 ($input_gamma) must be finite
30+ imagegammacorrect(): Argument #2 ($input_gamma) must be finite
31+ imagegammacorrect(): Argument #2 ($input_gamma) must be finite
32+ imagegammacorrect(): Argument #2 ($input_gamma) must be greater than 0
33+ imagegammacorrect(): Argument #3 ($output_gamma) must be finite
34+ imagegammacorrect(): Argument #3 ($output_gamma) must be finite
35+ imagegammacorrect(): Argument #3 ($output_gamma) must be finite
36+ imagegammacorrect(): Argument #3 ($output_gamma) must be greater than 0
You can’t perform that action at this time.
0 commit comments