diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 94450a0a2dcc3823fcbfb67d83b5bcbfb7359004..a97b8bbaa1cb4066fa1208fd462d8dcf39a6605f 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1436,7 +1436,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
                 }
             }
         }else{
-            for(i=0;i<6;i++)
+            for(i=0;i<12;i++)
                 s->block_last_index[i] = -1;
         }
     }