File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -2453,11 +2453,21 @@ PHP_FUNCTION(imagegammacorrect)
24532453 RETURN_THROWS ();
24542454 }
24552455
2456+ if (!zend_finite (input )) {
2457+ zend_argument_value_error (2 , "must be finite" );
2458+ RETURN_THROWS ();
2459+ }
2460+
24562461 if (output <= 0.0 ) {
24572462 zend_argument_value_error (3 , "must be greater than 0" );
24582463 RETURN_THROWS ();
24592464 }
24602465
2466+ if (!zend_finite (output )) {
2467+ zend_argument_value_error (3 , "must be finite" );
2468+ RETURN_THROWS ();
2469+ }
2470+
24612471 gamma = input / output ;
24622472
24632473 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