--- SDL_image/IMG_gif.orig.c	2008-02-01 11:58:19.000000000 +0100
+++ SDL_image/IMG_gif.c	2008-02-01 11:58:28.000000000 +0100
@@ -415,6 +415,10 @@
     static int table[2][(1 << MAX_LWZ_BITS)];
     static int stack[(1 << (MAX_LWZ_BITS)) * 2], *sp;
     register int i;
+    
+    /* Fixed buffer overflow found by Michael Skladnikiewicz */
+    if( input_code_size > MAX_LWZ_BITS )
+        return -1;
 
     if (flag) {
 	set_code_size = input_code_size;
