-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected nan value in ext/gd/libgd/gd_filter.c:386 #16255
Comments
seems the issue had been fixed upstream, issue only on the bundled version. |
Simplified reproducer: $matrix = array(array(1, 0, 1), array(0, 5, 0), array(1, 0, 1));
$im = imagecreatetruecolor(40, 40);
imageconvolution($im, $matrix, 0, 1.0); The problem is that we're passing zero as Anyhow, I think we should catch that early, i.e. ext/gd/gd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 899dc05b3e..68ede9d023 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -3759,6 +3759,10 @@ PHP_FUNCTION(imageconvolution)
}
}
}
+ if (div == 0.0) {
+ zend_argument_value_error(3, "must not be zero");
+ RETURN_THROWS();
+ }
res = gdImageConvolution(im_src, matrix, (float)div, (float)offset);
if (res) { I'm not sure whether checking for |
That's not enough:
I'll prepare a PR. |
* PHP-8.3: Fix GH-16255: Unexpected nan value in ext/gd/libgd/gd_filter.c
Description
The following code:
Resulted in this output:
PHP Version
PHP 8.4.0-dev
Operating System
ubuntu 22.04
The text was updated successfully, but these errors were encountered: