summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-11-20 17:51:37 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2021-11-20 17:51:37 +0000
commit4f20f753689e93c8448c58fd9c4245e0817298fa (patch)
tree17989ffdcd0842753df9b1e2ad0d82876feb956a
parent2487a3b82a88ce5d2c44028ebb1e86e22a2ed179 (diff)
downloadlibnsgif-4f20f753689e93c8448c58fd9c4245e0817298fa.tar.gz
libnsgif-4f20f753689e93c8448c58fd9c4245e0817298fa.tar.bz2
GIF: Simplify check for no frame data.
-rw-r--r--src/libnsgif.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libnsgif.c b/src/libnsgif.c
index 6a93dc8..5ba092a 100644
--- a/src/libnsgif.c
+++ b/src/libnsgif.c
@@ -67,9 +67,6 @@ enum gif_disposal {
#define GIF_BLOCK_TERMINATOR 0x00
#define GIF_TRAILER 0x3b
-/** standard GIF header size */
-#define GIF_STANDARD_HEADER_SIZE 13
-
static gif_result gif_error_from_lzw(lzw_result l_res)
{
static const gif_result g_res[] = {
@@ -1247,6 +1244,9 @@ gif_result gif_initialise(gif_animation *gif, size_t size, const uint8_t *data)
return ret;
}
+ /* Remember we've done this now */
+ gif->buffer_position = gif_data - gif->gif_data;
+
/* Some broken GIFs report the size as the screen size they
* were created in. As such, we detect for the common cases and
* set the sizes as 0 if they are found which results in the
@@ -1286,16 +1286,11 @@ gif_result gif_initialise(gif_animation *gif, size_t size, const uint8_t *data)
* termination block) Although generally useless, the GIF
* specification does not expressly prohibit this
*/
- if (gif->buffer_size == (GIF_STANDARD_HEADER_SIZE + 1)) {
+ if (gif->buffer_size == gif->buffer_position + 1) {
if (gif_data[0] == GIF_TRAILER) {
return GIF_OK;
- } else {
- return GIF_INSUFFICIENT_DATA;
}
}
-
- /* Remember we've done this now */
- gif->buffer_position = gif_data - gif->gif_data;
}
/* Do the colour map if we haven't already. As the top byte is always