diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index c13b76969b2acfd4cfc6529fed650fec2cfad627..c3b480f18d933c4eb6ac40b7793ab44bd0d50399 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -496,7 +496,7 @@ static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs,
                 dst[idx++] = alpha_val >> 6;
             else
                 dst[idx++] = (alpha_val << 2) | (alpha_val >> 6);
-            if (idx == num_coeffs - 1)
+            if (idx >= num_coeffs - 1)
                 break;
         } while (get_bits1(gb));
         val = get_bits(gb, 4);