summaryrefslogtreecommitdiff
path: root/src/libnsgif.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-11-20 19:22:39 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2021-11-20 19:25:38 +0000
commit032e62c80df60b5fcedcd75f3043e0a18e114b6e (patch)
tree635168810cffcf49a2e97991f9d546bd5a678195 /src/libnsgif.c
parent4f20f753689e93c8448c58fd9c4245e0817298fa (diff)
downloadlibnsgif-032e62c80df60b5fcedcd75f3043e0a18e114b6e.tar.gz
libnsgif-032e62c80df60b5fcedcd75f3043e0a18e114b6e.tar.bz2
GIF: Delay LZW creation until frame proccessing.
Diffstat (limited to 'src/libnsgif.c')
-rw-r--r--src/libnsgif.c16
1 files changed, 8 insertions, 8 deletions
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);