diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
index 17f7a19..375b152 100644
--- a/tools/gif2tiff.c
+++ b/tools/gif2tiff.c
@@ -333,6 +333,10 @@ readraster(void)
int status = 1;
datasize = getc(infile);
+
+ if (datasize > 12)
+ return 0;
+
clear = 1 << datasize;
eoi = clear + 1;
avail = clear + 2;