@@ -142,7 +142,7 @@ static avifBool isAvifSrgbImage(avifImage *avifIm) {
142
142
*/
143
143
static avifBool isAvifError (avifResult result , const char * msg ) {
144
144
if (result != AVIF_RESULT_OK ) {
145
- gd_error ("avif error - %s: %s" , msg , avifResultToString (result ));
145
+ gd_error ("avif error - %s: %s\n " , msg , avifResultToString (result ));
146
146
return AVIF_TRUE ;
147
147
}
148
148
@@ -168,13 +168,18 @@ static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, s
168
168
void * dataBuf = NULL ;
169
169
gdIOCtx * ctx = (gdIOCtx * ) io -> data ;
170
170
171
+ // readFlags is unsupported
172
+ if (readFlags != 0 ) {
173
+ return AVIF_RESULT_IO_ERROR ;
174
+ }
175
+
171
176
// TODO: if we set sizeHint, this will be more efficient.
172
177
173
- if (offset > LONG_MAX || size < 0 )
178
+ if (offset > INT_MAX || size > INT_MAX )
174
179
return AVIF_RESULT_IO_ERROR ;
175
180
176
181
// Try to seek offset bytes forward. If we pass the end of the buffer, throw an error.
177
- if (!ctx -> seek (ctx , offset ))
182
+ if (!ctx -> seek (ctx , ( int ) offset ))
178
183
return AVIF_RESULT_IO_ERROR ;
179
184
180
185
dataBuf = avifAlloc (size );
@@ -185,7 +190,7 @@ static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, s
185
190
186
191
// Read the number of bytes requested.
187
192
// If getBuf() returns a negative value, that means there was an error.
188
- int charsRead = ctx -> getBuf (ctx , dataBuf , size );
193
+ int charsRead = ctx -> getBuf (ctx , dataBuf , ( int ) size );
189
194
if (charsRead < 0 ) {
190
195
avifFree (dataBuf );
191
196
return AVIF_RESULT_IO_ERROR ;
@@ -330,7 +335,7 @@ gdImagePtr gdImageCreateFromAvifPtr(int size, void *data)
330
335
*/
331
336
gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx * ctx )
332
337
{
333
- int x , y ;
338
+ uint32_t x , y ;
334
339
gdImage * im = NULL ;
335
340
avifResult result ;
336
341
avifIO * io ;
@@ -465,7 +470,7 @@ void gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
465
470
466
471
uint32_t val ;
467
472
uint8_t * p ;
468
- int x , y ;
473
+ uint32_t x , y ;
469
474
470
475
if (im == NULL )
471
476
return ;
0 commit comments