Skip to content

Commit 87dbb32

Browse files
marandallcmb69
authored andcommitted
Negative checks for gamma
1 parent af8ecb3 commit 87dbb32

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ext/gd/gd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,8 +2445,8 @@ PHP_FUNCTION(imagegammacorrect)
24452445
}
24462446

24472447
if ( input <= 0.0 || output <= 0.0 ) {
2448-
php_error_docref(NULL, E_WARNING, "Gamma values should be positive");
2449-
RETURN_FALSE;
2448+
zend_throw_error(NULL, "Gamma values must be positive");
2449+
return;
24502450
}
24512451

24522452
gamma = input / output;

ext/gd/tests/bug72730.phpt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ if (!function_exists("imagecreatetruecolor")) die("skip");
66
?>
77
--FILE--
88
<?php
9+
10+
require __DIR__ . '/func.inc';
11+
912
$img = imagecreatetruecolor(1, 1);
10-
imagegammacorrect($img, -1, 1337);
13+
14+
trycatch_dump(
15+
fn() => imagegammacorrect($img, -1, 1337)
16+
);
17+
1118
?>
12-
DONE
13-
--EXPECTF--
14-
Warning: imagegammacorrect(): Gamma values should be positive in %sbug72730.php on line %d
15-
DONE
19+
--EXPECT--
20+
!! [Error] Gamma values must be positive

0 commit comments

Comments
 (0)