mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Backport libgd commit
Source - f6a111c632
Related to https://github.com/php/php-src/pull/5127#issuecomment-884032991
This commit is contained in:
parent
9e787d51b5
commit
bb9ef2bedb
1 changed files with 11 additions and 6 deletions
|
@ -142,7 +142,7 @@ static avifBool isAvifSrgbImage(avifImage *avifIm) {
|
||||||
*/
|
*/
|
||||||
static avifBool isAvifError(avifResult result, const char *msg) {
|
static avifBool isAvifError(avifResult result, const char *msg) {
|
||||||
if (result != AVIF_RESULT_OK) {
|
if (result != AVIF_RESULT_OK) {
|
||||||
gd_error("avif error - %s: %s", msg, avifResultToString(result));
|
gd_error("avif error - %s: %s\n", msg, avifResultToString(result));
|
||||||
return AVIF_TRUE;
|
return AVIF_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,13 +168,18 @@ static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, s
|
||||||
void *dataBuf = NULL;
|
void *dataBuf = NULL;
|
||||||
gdIOCtx *ctx = (gdIOCtx *) io->data;
|
gdIOCtx *ctx = (gdIOCtx *) io->data;
|
||||||
|
|
||||||
|
// readFlags is unsupported
|
||||||
|
if (readFlags != 0) {
|
||||||
|
return AVIF_RESULT_IO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: if we set sizeHint, this will be more efficient.
|
// TODO: if we set sizeHint, this will be more efficient.
|
||||||
|
|
||||||
if (offset > LONG_MAX || size < 0)
|
if (offset > INT_MAX || size > INT_MAX)
|
||||||
return AVIF_RESULT_IO_ERROR;
|
return AVIF_RESULT_IO_ERROR;
|
||||||
|
|
||||||
// Try to seek offset bytes forward. If we pass the end of the buffer, throw an error.
|
// Try to seek offset bytes forward. If we pass the end of the buffer, throw an error.
|
||||||
if (!ctx->seek(ctx, offset))
|
if (!ctx->seek(ctx, (int) offset))
|
||||||
return AVIF_RESULT_IO_ERROR;
|
return AVIF_RESULT_IO_ERROR;
|
||||||
|
|
||||||
dataBuf = avifAlloc(size);
|
dataBuf = avifAlloc(size);
|
||||||
|
@ -185,7 +190,7 @@ static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, s
|
||||||
|
|
||||||
// Read the number of bytes requested.
|
// Read the number of bytes requested.
|
||||||
// If getBuf() returns a negative value, that means there was an error.
|
// If getBuf() returns a negative value, that means there was an error.
|
||||||
int charsRead = ctx->getBuf(ctx, dataBuf, size);
|
int charsRead = ctx->getBuf(ctx, dataBuf, (int) size);
|
||||||
if (charsRead < 0) {
|
if (charsRead < 0) {
|
||||||
avifFree(dataBuf);
|
avifFree(dataBuf);
|
||||||
return AVIF_RESULT_IO_ERROR;
|
return AVIF_RESULT_IO_ERROR;
|
||||||
|
@ -330,7 +335,7 @@ gdImagePtr gdImageCreateFromAvifPtr(int size, void *data)
|
||||||
*/
|
*/
|
||||||
gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
|
gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
|
||||||
{
|
{
|
||||||
int x, y;
|
uint32_t x, y;
|
||||||
gdImage *im = NULL;
|
gdImage *im = NULL;
|
||||||
avifResult result;
|
avifResult result;
|
||||||
avifIO *io;
|
avifIO *io;
|
||||||
|
@ -465,7 +470,7 @@ void gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
|
||||||
|
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
int x, y;
|
uint32_t x, y;
|
||||||
|
|
||||||
if (im == NULL)
|
if (im == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue