+ off_check = off;
+ gb_check = gb;
+ for (slice = 0; slice < nslices; slice++) {
+ slice_size = bytestream2_get_le32(&gb_check);
+
+ if (slice_size <= 16 + (avctx->height * avctx->width / (8 * nslices)))
+ return AVERROR_INVALIDDATA;
+ off_check += slice_size;
+ }
+
+ if (off_check - avctx->discard_damaged_percentage*off_check/100 > src_size)
+ return AVERROR_INVALIDDATA;
+