mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Restore Warning instead of Fatal Error in gd_webp.c
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). Close GH-13774
This commit is contained in:
parent
09957ab9a8
commit
b456ae8d34
1
NEWS
1
NEWS
@ -16,6 +16,7 @@ PHP NEWS
|
|||||||
|
|
||||||
- Gd:
|
- Gd:
|
||||||
. ext/gd/tests/gh10614.phpt: skip if no PNG support. (orlitzky)
|
. ext/gd/tests/gh10614.phpt: skip if no PNG support. (orlitzky)
|
||||||
|
. restored warning instead of fata error. (dryabov)
|
||||||
|
|
||||||
- LibXML:
|
- LibXML:
|
||||||
. Fixed bug GH-14563 (Build failure with libxml2 v2.13.0). (nielsdos)
|
. Fixed bug GH-14563 (Build failure with libxml2 v2.13.0). (nielsdos)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "gd.h"
|
#include "gd.h"
|
||||||
|
#include "gd_errors.h"
|
||||||
#include "gdhelpers.h"
|
#include "gdhelpers.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBWEBP
|
#ifdef HAVE_LIBWEBP
|
||||||
@ -56,7 +57,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
|
|||||||
if (filedata) {
|
if (filedata) {
|
||||||
gdFree(filedata);
|
gdFree(filedata);
|
||||||
}
|
}
|
||||||
zend_error(E_ERROR, "WebP decode: realloc failed");
|
gd_error("WebP decode: realloc failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
|
|||||||
} while (n>0 && n!=EOF);
|
} while (n>0 && n!=EOF);
|
||||||
|
|
||||||
if (WebPGetInfo(filedata,size, &width, &height) == 0) {
|
if (WebPGetInfo(filedata,size, &width, &height) == 0) {
|
||||||
zend_error(E_ERROR, "gd-webp cannot get webp info");
|
gd_error("gd-webp cannot get webp info");
|
||||||
gdFree(filedata);
|
gdFree(filedata);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
|
|||||||
}
|
}
|
||||||
argb = WebPDecodeARGB(filedata, size, &width, &height);
|
argb = WebPDecodeARGB(filedata, size, &width, &height);
|
||||||
if (!argb) {
|
if (!argb) {
|
||||||
zend_error(E_ERROR, "gd-webp cannot allocate temporary buffer");
|
gd_error("gd-webp cannot allocate temporary buffer");
|
||||||
gdFree(filedata);
|
gdFree(filedata);
|
||||||
gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -113,7 +114,7 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gdImageTrueColor(im)) {
|
if (!gdImageTrueColor(im)) {
|
||||||
zend_error(E_ERROR, "Palette image not supported by webp");
|
gd_error("Palette image not supported by webp");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out_size == 0) {
|
if (out_size == 0) {
|
||||||
zend_error(E_ERROR, "gd-webp encoding failed");
|
gd_error("gd-webp encoding failed");
|
||||||
goto freeargb;
|
goto freeargb;
|
||||||
}
|
}
|
||||||
gdPutBuf(out, out_size, outfile);
|
gdPutBuf(out, out_size, outfile);
|
||||||
|
Loading…
Reference in New Issue
Block a user