diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 507375f98e81cfc7a7c6e5a57dfdc03f99ac7604..4af4a0d3edbcf7b81839f8644ae3fb394f7fe308 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -512,6 +512,8 @@ resync:
 
             first = get_byte(pb);
             clr = get_byte(pb);
+	    if(!clr) /* all 256 colors used */
+		clr = 256;
             flags = get_le16(pb);
             p = 4;
             for (k = first; k < clr + first; k++) {