-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Restore Warning instead of Fatal Error in gd_webp.c #13774
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
Conversation
According to the docs (https://www.php.net/manual/en/function.imagecreatefromwebp.php and https://www.php.net/manual/en/function.imagewebp.php), `false` should be returned on errors (similar to other functions of the `gd` extension), but actually all errors result in a `Fatal Error`. It doesn't look normal when trying to read an empty file or a file in the wrong format causes the program to stop. The problem seems to be related to a mega-patch that replaced `zend_error` with `zend_error_noreturn` almost everywhere. My patch fixes this behavior by switching from `zend_error_noerror` to `gd_error` (i.e. to `E_WARNING` level). All necessary memory cleanup is already in the code (as it was before the "zend_error_noreturn" patch).
Ugh, that is pretty strange, since |
No, that is not the issue. You will get the same behavior prior to that commit. The problem is indeed that I had replaced The patch looks fine, but we should probably target @devnexen, what do think? @dryabov, would you take care of this? |
Absolutely no objection on my part, however release managers might have a say too. |
Ah, right! So asking the PHP 8.2 release managers if they have concerns targeting |
Lgtm. I agree that an error in an image file shouldn't trigger a fatal. |
Thank you ! |
Besides demonstrating the new behavior, this test also ensures that the bundled and external libgd now behave the same. It has to be noted, though, that we only test one of the five code paths.
I've commented on the commit, but I do think the allocation failures using |
Besides demonstrating the new behavior, this test also ensures that the bundled and external libgd now behave the same. It has to be noted, though, that we only test one of the five code paths. Closes GH-14945.
* PHP-8.2: Add test case for GH-13774
* PHP-8.3: Add test case for GH-13774
According to the docs (see https://www.php.net/manual/en/function.imagecreatefromwebp.php and https://www.php.net/manual/en/function.imagewebp.php),
false
should be returned on errors (similar to other functions of thegd
extension), but actually all errors result in aFatal Error
. It doesn't look normal when trying to read an empty file or a file in the wrong format causes the program to stop.The problem seems to be related to a mega-patch that replaced
zend_error
withzend_error_noreturn
almost everywhere.My patch fixes this behavior by switching from
zend_error_noerror
togd_error
(i.e. toE_WARNING
level). All necessary memory cleanup is already in the code (as it was before the "zend_error_noreturn" patch).You can use the following code to test:
Current result:
Expected result: