From 032e62c80df60b5fcedcd75f3043e0a18e114b6e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 20 Nov 2021 19:22:39 +0000 Subject: GIF: Delay LZW creation until frame proccessing. --- src/libnsgif.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libnsgif.c b/src/libnsgif.c index 5ba092a..6c21a7c 100644 --- a/src/libnsgif.c +++ b/src/libnsgif.c @@ -1207,14 +1207,6 @@ gif_result gif_initialise(gif_animation *gif, size_t size, const uint8_t *data) gif->buffer_size = size; gif->gif_data = data; - if (gif->lzw_ctx == NULL) { - lzw_result res = lzw_context_create( - (struct lzw_ctx **)&gif->lzw_ctx); - if (res != LZW_OK) { - return gif_error_from_lzw(res); - } - } - /* Get our current processing position */ gif_data = gif->gif_data + gif->buffer_position; @@ -1331,6 +1323,14 @@ gif_result gif_initialise(gif_animation *gif, size_t size, const uint8_t *data) } } + if (gif->lzw_ctx == NULL) { + lzw_result res = lzw_context_create( + (struct lzw_ctx **)&gif->lzw_ctx); + if (res != LZW_OK) { + return gif_error_from_lzw(res); + } + } + /* Repeatedly try to initialise frames */ do { ret = gif__process_frame(gif, gif->frame_count, false); -- cgit v1.2.3