[gdk-pixbuf: 4/7] gif: Fix clear code handling when at end of a block



commit 88ceed9ed1e823ffd797df798d429d15bc7efd39
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Dec 12 12:46:44 2018 +1300

    gif: Fix clear code handling when at end of a block
    
    The following was occurring:
    1. A clear code is detected in the LZW stream.
    2. The decoder enters a clear code handling state.
    3. The decoder looks for the next code after the clear.
    4. The decoder has run out of blocks, so enters a state to get new blocks
    
    The issue is in step 4 the decoder has assumed the clear state is complete,
    when it is not. The solution is to only complete the clear state once a
    non clear code is read.
    
    This caused the "Circular table entry in GIF file" error for some GIFs.
    Fixes https://gitlab.gnome.org/GNOME/gdk-pixbuf/issues/27
    Fixes https://gitlab.gnome.org/GNOME/gdk-pixbuf/issues/69

 gdk-pixbuf/io-gif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 244d8788f..f2207360e 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -572,7 +572,6 @@ lzw_read_byte (GifContext *context)
        register int i;
 
        if (context->lzw_fresh) {
-               context->lzw_fresh = FALSE;
                do {
                        retval = get_code (context, context->lzw_code_size);
                        if (retval < 0) {
@@ -581,6 +580,7 @@ lzw_read_byte (GifContext *context)
 
                        context->lzw_firstcode = context->lzw_oldcode = retval;
                } while (context->lzw_firstcode == context->lzw_clear_code);
+               context->lzw_fresh = FALSE;
                return context->lzw_firstcode;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]