diff --git a/libvips/foreign/libnsgif/libnsgif.c b/libvips/foreign/libnsgif/libnsgif.c index 382ae33f..429bcd1a 100644 --- a/libvips/foreign/libnsgif/libnsgif.c +++ b/libvips/foreign/libnsgif/libnsgif.c @@ -82,8 +82,8 @@ gif_initialise_sprite(gif_animation *gif, unsigned int width, unsigned int height) { - /* Already allocated? */ - if (gif->frame_image) { + /* Already allocated? */ + if (gif->frame_image) { return GIF_OK; } @@ -378,12 +378,12 @@ static gif_result gif_initialise_frame(gif_animation *gif) gif->frames[frame].redraw_required = ((gif->frames[frame].disposal_method == GIF_FRAME_CLEAR) || (gif->frames[frame].disposal_method == GIF_FRAME_RESTORE)); - /* Frame size may have grown. - */ - gif->width = (offset_x + width > gif->width) ? - offset_x + width : gif->width; - gif->height = (offset_y + height > gif->height) ? - offset_y + height : gif->height; + /* Frame size may have grown. + */ + gif->width = (offset_x + width > gif->width) ? + offset_x + width : gif->width; + gif->height = (offset_y + height > gif->height) ? + offset_y + height : gif->height; /* Decode the flags */ flags = gif_data[9]; @@ -878,9 +878,9 @@ gif_internal_decode_frame(gif_animation *gif, goto gif_decode_frame_exit; } - /* Make sure we have a buffer to decode to. - */ - if (gif_initialise_sprite(gif, gif->width, gif->height)) { + /* Make sure we have a buffer to decode to. + */ + if (gif_initialise_sprite(gif, gif->width, gif->height)) { return GIF_INSUFFICIENT_MEMORY; } diff --git a/libvips/foreign/libnsgif/patches/delay-alloc.patch b/libvips/foreign/libnsgif/patches/delay-alloc.patch deleted file mode 100644 index 21630f2b..00000000 --- a/libvips/foreign/libnsgif/patches/delay-alloc.patch +++ /dev/null @@ -1,86 +0,0 @@ ---- libnsgif-orig.c 2021-04-03 12:23:43.700260070 +0100 -+++ libnsgif.c 2021-04-03 12:24:44.079567702 +0100 -@@ -79,34 +79,17 @@ - unsigned int width, - unsigned int height) - { -- unsigned int max_width; -- unsigned int max_height; -- struct bitmap *buffer; -- -- /* Check if we've changed */ -- if ((width <= gif->width) && (height <= gif->height)) { -+ /* Already allocated? */ -+ if (gif->frame_image) { - return GIF_OK; - } - -- /* Get our maximum values */ -- max_width = (width > gif->width) ? width : gif->width; -- max_height = (height > gif->height) ? height : gif->height; -- -- /* Allocate some more memory */ - assert(gif->bitmap_callbacks.bitmap_create); -- buffer = gif->bitmap_callbacks.bitmap_create(max_width, max_height); -- if (buffer == NULL) { -+ gif->frame_image = gif->bitmap_callbacks.bitmap_create(width, height); -+ if (gif->frame_image == NULL) { - return GIF_INSUFFICIENT_MEMORY; - } - -- assert(gif->bitmap_callbacks.bitmap_destroy); -- gif->bitmap_callbacks.bitmap_destroy(gif->frame_image); -- gif->frame_image = buffer; -- gif->width = max_width; -- gif->height = max_height; -- -- /* Invalidate our currently decoded image */ -- gif->decoded_frame = GIF_INVALID_FRAME; - return GIF_OK; - } - -@@ -392,10 +375,12 @@ - gif->frames[frame].redraw_required = ((gif->frames[frame].disposal_method == GIF_FRAME_CLEAR) || - (gif->frames[frame].disposal_method == GIF_FRAME_RESTORE)); - -- /* Boundary checking - shouldn't ever happen except with junk data */ -- if (gif_initialise_sprite(gif, (offset_x + width), (offset_y + height))) { -- return GIF_INSUFFICIENT_MEMORY; -- } -+ /* Frame size may have grown. -+ */ -+ gif->width = (offset_x + width > gif->width) ? -+ offset_x + width : gif->width; -+ gif->height = (offset_y + height > gif->height) ? -+ offset_y + height : gif->height; - - /* Decode the flags */ - flags = gif_data[9]; -@@ -739,6 +724,12 @@ - goto gif_decode_frame_exit; - } - -+ /* Make sure we have a buffer to decode to. -+ */ -+ if (gif_initialise_sprite(gif, gif->width, gif->height)) { -+ return GIF_INSUFFICIENT_MEMORY; -+ } -+ - /* Decode the flags */ - flags = gif_data[9]; - colour_table_size = 2 << (flags & GIF_COLOUR_TABLE_SIZE_MASK); -@@ -1115,14 +1106,6 @@ - } - gif->frame_holders = 1; - -- /* Initialise the bitmap header */ -- assert(gif->bitmap_callbacks.bitmap_create); -- gif->frame_image = gif->bitmap_callbacks.bitmap_create(gif->width, gif->height); -- if (gif->frame_image == NULL) { -- gif_finalise(gif); -- return GIF_INSUFFICIENT_MEMORY; -- } -- - /* Remember we've done this now */ - gif->buffer_position = gif_data - gif->gif_data; - }